I need to sort all of the data in my worksheet by Column G from smallest to largest, and the data has a header row.
Currently, I have 436 lines of data (plus the header row)
The code I have is:
ActiveWorkbook.Worksheets(FName).Sort.SortFields.Clear
ActiveWorkbook.Worksheets(FName).Sort.SortFields.Add Key:=Range( _
"G2:G437"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets(FName).Sort
.SetRange Range("A1:J437")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
So my questions are:
- What do I replace G2:G437 with so that it always sorts all of the records?
- What do I replace A1:J437 with so that it always has the full range of records (I could add columns or rows)?
Thank you for any help!
Currently, I have 436 lines of data (plus the header row)
The code I have is:
ActiveWorkbook.Worksheets(FName).Sort.SortFields.Clear
ActiveWorkbook.Worksheets(FName).Sort.SortFields.Add Key:=Range( _
"G2:G437"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets(FName).Sort
.SetRange Range("A1:J437")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
So my questions are:
- What do I replace G2:G437 with so that it always sorts all of the records?
- What do I replace A1:J437 with so that it always has the full range of records (I could add columns or rows)?
Thank you for any help!