M
mc
I don't know what the difference is between these 2 pieces of code. The
first piece works but the second is giving the error message of "Error: 1004
- The sort reference is not valid. Make sure that it's within the data you
want to sort, and the first Sort By Box isn't the same or blank".
First piece of coding:
xl_WksheetData.Range("A1").Select
Range("A1" & CStr(intLastRow)).Sort Key1:=Range("C2"),
Order1:=xlAscending, Key2:=Range _
("E2"), Order2:=xlAscending, Key3:=Range("D2"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
2nd piece of coding:
xl_WksheetData.Range("A1").Select
xl_WksheetData.Range("A1" & CStr(intLastRow)).Sort Key1:=Range("C2"),
Order1:=xlAscending, Key2:=Range _
("E2"), Order2:=xlAscending, Key3:=Range("D2"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
first piece works but the second is giving the error message of "Error: 1004
- The sort reference is not valid. Make sure that it's within the data you
want to sort, and the first Sort By Box isn't the same or blank".
First piece of coding:
xl_WksheetData.Range("A1").Select
Range("A1" & CStr(intLastRow)).Sort Key1:=Range("C2"),
Order1:=xlAscending, Key2:=Range _
("E2"), Order2:=xlAscending, Key3:=Range("D2"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
2nd piece of coding:
xl_WksheetData.Range("A1").Select
xl_WksheetData.Range("A1" & CStr(intLastRow)).Sort Key1:=Range("C2"),
Order1:=xlAscending, Key2:=Range _
("E2"), Order2:=xlAscending, Key3:=Range("D2"), Order3:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal