Good Morning!
I was hoping someone could help with some older vba coding. A new spreadsheet desperately needs to be adjusted but I only have the sort code when I removed the header rows in a test sheet so that I could at least get that much to post here. Sorting 2 different ways but column B (Name) then C (Department) and then by column C (Department) followed by B (Name) but I don't know how to accommodate the header rows in the sort so that these aren't sorted into the data. Here is the preliminary code for both:
****************
Sub SortByName_NoHeaderRow()
'
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Key2:=Range( _
"D1"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Range("C1").Select
End Sub
****************
Sub SortByDepart_NoHeaderRow()
'
Selection.Sort Key1:=Range("D1"), Order1:=xlAscending, Key2:=Range( _
"C1"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Range("D1").Select
End Sub
****************
The header rows cover 4 rows (or, from 1-4, ::, naturally).
Thank you so much, if anyone can help. And this has to remain in XL2003 code, unfortunately. Cheers.
I was hoping someone could help with some older vba coding. A new spreadsheet desperately needs to be adjusted but I only have the sort code when I removed the header rows in a test sheet so that I could at least get that much to post here. Sorting 2 different ways but column B (Name) then C (Department) and then by column C (Department) followed by B (Name) but I don't know how to accommodate the header rows in the sort so that these aren't sorted into the data. Here is the preliminary code for both:
****************
Sub SortByName_NoHeaderRow()
'
Selection.Sort Key1:=Range("C1"), Order1:=xlAscending, Key2:=Range( _
"D1"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Range("C1").Select
End Sub
****************
Sub SortByDepart_NoHeaderRow()
'
Selection.Sort Key1:=Range("D1"), Order1:=xlAscending, Key2:=Range( _
"C1"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal
Range("D1").Select
End Sub
****************
The header rows cover 4 rows (or, from 1-4, ::, naturally).
Thank you so much, if anyone can help. And this has to remain in XL2003 code, unfortunately. Cheers.
Last edited: