TheWennerWoman
Active Member
- Joined
- Aug 1, 2019
- Messages
- 270
- Office Version
- 365
- Platform
- Windows
Hope someone can help, I'm really puzzled by this. Basically, I am looking to sort a dataset based on column AY (smallest to largest). This is my code:
The variable lastrow is declared just fine but this falls over with
I think I might even have used the macro recorder to get the code in the first place so I'm totally confused!
Code:
Columns("A:DY").Select
Range("DY1").Activate
ActiveWorkbook.Worksheets("7c. Consolidated Tagetik Input").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("7c. Consolidated Tagetik Input").Sort.SortFields.Add2 Key:=Range("DY2:DY" & lastrow), SortOn:=xlSortOnValues, Order:=xlAscending _
, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("7c. Consolidated Tagetik Input").Sort
.SetRange Range("A1:DY" & lastrow)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
The variable lastrow is declared just fine but this falls over with
Code:
Run time error 438: object doesn't support this property or method
I think I might even have used the macro recorder to get the code in the first place so I'm totally confused!