What is add2 for sortfields

前端 未结 2 562
孤独总比滥情好
孤独总比滥情好 2020-11-30 14:13

When I use the macro recorder on sorting a ListObject (table), it produces:

ActiveWorkbook.Worksheets(\"Output\").ListObjects(\"Table4\").Sort.SortFields.Add         


        
2条回答
  •  孤独总比滥情好
    2020-11-30 14:57

    Add2 is a method on SortFields only available in newer versions of Excel. The difference to Add is that Add2 supports a subfield parameter. For example in a geography field you can sort by population.

    The macro recorder uses Add2 to support sorting by subfields. If you don't need to sort by subfields then you can change the recorded code to Add and it will work on older versions of Excel.

提交回复
热议问题