ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Afternoon,
Below is the code currently in use to sort column A in A-Z order
The downside is that i also have the same code repeated on the sheet to sort column B,C,D,E,F & G
So as you can imagine my page has a long lists of the same code but with the column letter changed.
So i am looking for a code to use on a userform.
On the userform would be a drop down list with the column names in & a command button.
It should work by the user selecting the column name they require sorting then the command button would carry out the sort A-Z.
If possible it would be nice to have in the drop down list the actual name of the column example "VIN" as apposed to the column letter A
Have a nice day.
Below is the code currently in use to sort column A in A-Z order
The downside is that i also have the same code repeated on the sheet to sort column B,C,D,E,F & G
So as you can imagine my page has a long lists of the same code but with the column letter changed.
So i am looking for a code to use on a userform.
On the userform would be a drop down list with the column names in & a command button.
It should work by the user selecting the column name they require sorting then the command button would carry out the sort A-Z.
If possible it would be nice to have in the drop down list the actual name of the column example "VIN" as apposed to the column letter A
Have a nice day.
VBA Code:
Private Sub SortVinButton_Click()
Dim x As Long
Application.ScreenUpdating = False
With Sheets("HONDA LIST")
If .AutoFilterMode Then .AutoFilterMode = False
x = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range("A3:G" & x).Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlGuess
End With
ActiveWorkbook.Save
Application.ScreenUpdating = True
Sheets("HONDA LIST").Range("A4").Select
End Sub