Jaymond Flurrie
Well-known Member
- Joined
- Sep 22, 2008
- Messages
- 921
- Office Version
- 365
- Platform
- Windows
What kind of "For Each"-loop do I need to sort ascending all the tables I have in a sheet? Each of them should be sorted by the first column of the table.
I don't know how to point to that first column of the table. Here's the code that I have - naturally it doesn't work since that Key:=Range("[]") should be filled with something:
I don't know how to point to that first column of the table. Here's the code that I have - naturally it doesn't work since that Key:=Range("[]") should be filled with something:
Code:
Sub Makro8()
Dim loX As ListObject
For Each loX In Worksheets("Databases").ListObjects
With loX.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("[]"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Next loX
End Sub