novabond
New Member
- Joined
- Mar 26, 2022
- Messages
- 36
- Office Version
- 365
- Platform
- Windows
hello.
I have inherited the below code, which works great but, ideally i would like the code to ask the user ´which column header to sort the table by´.....
which the user can either type manually or, if possible select from a list?
you will notice i have made the bit below, that i would like to be a InputBox, bigger and in red... I hope my question make sense..
I am looking forward to reading what you think... as i have spent quite a while trying to search for this myself but, cant seem to find what i am looking for easily online already...
TIA
Sub SortPasswordCategorys2()
Dim iSheet As Worksheet
Dim iTable As ListObject
Dim iColumn As Range
Set iSheet = ActiveSheet
Set iTable = iSheet.ListObjects("TBL_other_passwords")
Set iColumn = Range("TBL_other_passwords[Category]")
With iTable.Sort
.SortFields.Clear
.SortFields.Add Key:=iColumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
End Sub
I have inherited the below code, which works great but, ideally i would like the code to ask the user ´which column header to sort the table by´.....
which the user can either type manually or, if possible select from a list?
you will notice i have made the bit below, that i would like to be a InputBox, bigger and in red... I hope my question make sense..
I am looking forward to reading what you think... as i have spent quite a while trying to search for this myself but, cant seem to find what i am looking for easily online already...
TIA
Sub SortPasswordCategorys2()
Dim iSheet As Worksheet
Dim iTable As ListObject
Dim iColumn As Range
Set iSheet = ActiveSheet
Set iTable = iSheet.ListObjects("TBL_other_passwords")
Set iColumn = Range("TBL_other_passwords[Category]")
With iTable.Sort
.SortFields.Clear
.SortFields.Add Key:=iColumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
End Sub