eirikdaude
Board Regular
- Joined
- Nov 26, 2013
- Messages
- 93
- Office Version
- 365
- Platform
- Windows
I'm having a bit of trouble with sorting a table using VBA. The macro I'm using is this
However I get an error on the line ".SortFields.Add (...)" saying "Runtime error 438. Object doesn't support this property or method".
Can someone give me a pointer to where I'm going wrong?
VBA Code:
Private Sub test()
Dim lo As ListObject
Set lo = HCP_justering.ListObjects(1)
lo.AutoFilter.ShowAllData
With lo.Sort
.SortFields.Clear
.SortFields.Add _
Key:=lo.ListColumn(1).Range, _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.Header = xlYes
.MatchCase = True
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
However I get an error on the line ".SortFields.Add (...)" saying "Runtime error 438. Object doesn't support this property or method".
Can someone give me a pointer to where I'm going wrong?