VBA Sort table with 1 criteria

Опубликовано: 24 Октябрь 2024
на канале: Simplified Excellence
235
2

Sort a table based on one column or criteria

Code:
Sub sort_table_with_one_criteria()

Dim ws_sheet As Worksheet
Dim tbl As ListObject

'identify worksheet
Set ws_sheet = Worksheets(4)

'identify table
Set tbl = ws_sheet.ListObjects(1)

'sort by gender
With tbl.Sort
.SortFields.Clear
.SortFields.Add Key:=Range("Table1[Gender]"), SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With

End Sub

-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.

-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!