Select the whole table and run this subroutine, it will sort each column independently a-z
Test on a sample first though eh!
Sub sortCols()
For Each Column In Selection.Columns
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Column, _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Column
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Next
End Sub
If you use “Sort” in the data tab you can sort multiple columns alphabetically, you will just need to define the hierarchy of which columns take precedence.
That still sorts all columns together, and not individually as required for OP. It just means that where duplicate values occur at one level, the next level sort can be chosen too.
•
u/AutoModerator Sep 10 '21
/u/Ramza1890 - Your post was submitted successfully.
Solution Verifiedto close the thread.Failing to follow these steps may result in your post being removed without warning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/excelevator 3071 Sep 10 '21
sort a-z ?
1
u/7-khoon-maaf Sep 10 '21
How about sorting each column alphabetically and then copy transpose. Repeat again