Hi everyone
I have the fillowing VBA code that sorts data on the active named spreasheet (Final Data 1)
using the search order as specified in the code.
For each column it sorts Cell 2 - 31282 but this does not allow for rows being removed or added
so I need Excel to select All cells with data and then perform the sort.
I have tried various combinations of
for column A but Excel does not like my combinations and I need to apply to to all of the Columns in my VBA.
Can some one point me in the right directection?
I have the fillowing VBA code that sorts data on the active named spreasheet (Final Data 1)
using the search order as specified in the code.
For each column it sorts Cell 2 - 31282 but this does not allow for rows being removed or added
so I need Excel to select All cells with data and then perform the sort.
I have tried various combinations of
VBA Code:
Range("A1", Range("A1").End(xlDown)).Sort Key1:=Range("A1"), Order1:=xlAscending
Can some one point me in the right directection?
VBA Code:
Sub SortRowsAlphabetically()
ActiveWorkbook.Worksheets("Final Data 1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Final Data 1").Sort.SortFields.Add2 Key:=Range( _
"A2:A31282"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Final Data 1").Sort.SortFields.Add2 Key:=Range( _
"D2:D31282"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
ActiveWorkbook.Worksheets("Final Data 1").Sort.SortFields.Add2 Key:=Range( _
"E2:E31282"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Final Data 1").Sort.SortFields.Add2 Key:=Range( _
"J2:J31282"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Final Data 1").Sort
.SetRange Range("A1:J31282")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub