S
sylink
I recorded the macro below and need to modify it for use in varing number of records.
=============================================================
Range("A1:X1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("sectxW").SORT.SortFields.Clear
ActiveWorkbook.Worksheets("sectxW").SORT.SortFields.Add Key:=Range("A2:A7746" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("sectxW").SORT.SortFields.Add Key:=Range("F2:F7746" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("sectxW").SORT.SortFields.Add Key:=Range("I2:I7746" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("sectxW").SORT
.SetRange Range("A1:X7746")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
==========================================================================
I guess the following need to be modified to accept variable number of records :Range("A2:A7746"), Range("F2:F7746"),Range("I2:I7746"), Range("A1:X7746")
Thanks
=============================================================
Range("A1:X1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("sectxW").SORT.SortFields.Clear
ActiveWorkbook.Worksheets("sectxW").SORT.SortFields.Add Key:=Range("A2:A7746" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("sectxW").SORT.SortFields.Add Key:=Range("F2:F7746" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("sectxW").SORT.SortFields.Add Key:=Range("I2:I7746" _
), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("sectxW").SORT
.SetRange Range("A1:X7746")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
==========================================================================
I guess the following need to be modified to accept variable number of records :Range("A2:A7746"), Range("F2:F7746"),Range("I2:I7746"), Range("A1:X7746")
Thanks