preseb
04-13-2011, 06:34 AM
When I recorded the sort function, it provided me with the exact range that I am using.
I would like to clean it up so it does not matter how many rows my table is.
ActiveWorkbook.Worksheets("Master File").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Master File").Sort.SortFields.Add Key:=Range( _
"C2:C2339"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Master File").Sort.SortFields.Add Key:=Range( _
"B2:B2339"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Master File").Sort
.SetRange Range("A1:O2339")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
I would like to clean it up so it does not matter how many rows my table is.
ActiveWorkbook.Worksheets("Master File").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Master File").Sort.SortFields.Add Key:=Range( _
"C2:C2339"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Master File").Sort.SortFields.Add Key:=Range( _
"B2:B2339"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Master File").Sort
.SetRange Range("A1:O2339")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With