ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Morning,
I am using the code supplied below but noticed it doesnt sort correctly.
Do you see why or can you advise another code.
I have supplied some screen shot example of its sorting issue.
I am using the code supplied below but noticed it doesnt sort correctly.
Do you see why or can you advise another code.
I have supplied some screen shot example of its sorting issue.
VBA Code:
Private Sub CommandButton1_Click()
Dim x As Long
Dim ws As Worksheet
Set ws = Sheets("MC LIST")
Dim SortColumn As String
Select Case ComboBox1
Case "CUSTOMER"
SortColumn = "A"
Case "VIN"
SortColumn = "B"
Case "MAKE"
SortColumn = "C"
Case "MODEL"
SortColumn = "D"
Case "YEAR"
SortColumn = "E"
Case "ITEM BOUGHT"
SortColumn = "F"
Case "CHIP"
SortColumn = "G"
Case "COUNTRY"
SortColumn = "H"
Case "ORIGINAL PN"
SortColumn = "I"
End Select
If Len(SortColumn) <> 0 Then
Application.ScreenUpdating = False
With ws
If .AutoFilterMode Then .AutoFilterMode = False
x = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range("A7:I" & x).Sort Key1:=.Cells(2, SortColumn), Order1:=xlAscending, Header:=xlGuess
End With
End If
Unload AtoZMcList
End Sub
Private Sub UserForm_Initialize()
Dim rheadings As Range
Dim cl As Range
Set rheadings = Worksheets("MC LIST").Range("A6:I6")
For Each cl In rheadings
Me.ComboBox1.AddItem cl.Value
Next cl
End Sub