Hi,
I'm getting a Run-Time Error '438' when trying to sort some data.
I've read some of the previous forums hinting at a compatibility issue between excel 2003 and 2007, but that isn't the case here.
The sample code is as follows (A few lines may look wired b/c I was testing out ways to make it work):
Columns M and C work fine. C only started working after I added the "Sort.SortFields.Clear" line of code.
Columns A and I refuse to cooperate.
Please help!
I'm getting a Run-Time Error '438' when trying to sort some data.
I've read some of the previous forums hinting at a compatibility issue between excel 2003 and 2007, but that isn't the case here.
The sample code is as follows (A few lines may look wired b/c I was testing out ways to make it work):
Code:
Sub TestMacro()
ThisWorkbook.Worksheets("ListData").Activate
ThisWorkbook.Worksheets("ListData").Range("M1").EntireColumn.Sort key1:=Range("M1"), order1:=xlAscending, Header:=xlYes
ActiveWorkbook.Worksheets("ListData").Sort.SortFields.Clear
ThisWorkbook.Worksheets("ListData").Range("C1").EntireColumn.Sort key1:=Range("C1"), order1:=xlAscending, Header:=xlYes
ThisWorkbook.Worksheets("ListData").Sort.SortFields.Clear
ThisWorkbook.Worksheets("ListData").Range("A1").EntireCoulmn.Sort.SortFields SortOn:=xlSortOnValues, key1:=Range("A1"), order1:=xlAscending, DataOption:=xlSortNormal, Header:=xlYes
ActiveWorkbook.Worksheets("ListData").Sort.SortFields.Clear
ThisWorkbook.Worksheets("ListData").Range("I1").EntireCoulmn.Sort key1:=Range("I1"), order1:=xlAscending, Header:=xlYes
End Sub
Columns M and C work fine. C only started working after I added the "Sort.SortFields.Clear" line of code.
Columns A and I refuse to cooperate.
Please help!
