Hi, I've been trying to get some sort code to work but I got stuck.
The idea of the code is that it will be part of a "re-apply" button that will sit in a workbook that contains over 50 individual worksheets with their own tables.
From what I have understood so far to use the ListObject I would need to reference the table I want but considering there's over 50 of them...I want the an easier way out basically.
Is there a way that I can modify the code to act on whatever table exists on the worksheet that the button is pressed?
I should also probably mention this code goes into a bigger one, but I am just posting the section I am having issues with.
Really appreciate any help,
Thank you
The idea of the code is that it will be part of a "re-apply" button that will sit in a workbook that contains over 50 individual worksheets with their own tables.
From what I have understood so far to use the ListObject I would need to reference the table I want but considering there's over 50 of them...I want the an easier way out basically.
Is there a way that I can modify the code to act on whatever table exists on the worksheet that the button is pressed?
I should also probably mention this code goes into a bigger one, but I am just posting the section I am having issues with.
VBA Code:
Sub SortExample()
ActiveSheet.Sort. _
SortFields.Clear
ActiveSheets.Sort.SortFields.Add(Range("B38"), _
xlSortOnCellColor, xlDescending, , _
xlSortNormal).SortOnValue.Color = RGB(174, 170, 170)
ActiveSheet.Sort.SortFields.Add Key:=Range("B38"), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveSheet.Sort
.SetRange Range("B38").CurrentRegion
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Really appreciate any help,
Thank you