ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,983
- Office Version
- 2007
- Platform
- Windows
I am currently using the code shown below.
At the end of the code you will see Range A8 Select.
This is what i am seeing.
Say i am on Row 77, I then open the sort form, Make a selection & run the sort code.
The sort works fine BUT i am still on Row77 & i was expecting to be taken to cell A8
If i manually scroll using mouse wheel cell A8 is actually selected.
How else can i be taken there once code has run thus not leaving me on whatever row i was currently on
At the end of the code you will see Range A8 Select.
This is what i am seeing.
Say i am on Row 77, I then open the sort form, Make a selection & run the sort code.
The sort works fine BUT i am still on Row77 & i was expecting to be taken to cell A8
If i manually scroll using mouse wheel cell A8 is actually selected.
How else can i be taken there once code has run thus not leaving me on whatever row i was currently on
VBA Code:
Private Sub PressToSort_Click()
Dim x As Long
Dim ws As Worksheet
Set ws = Sheets("MCLIST")
Dim SortColumn As String
Select Case ComboBox1
Case "CUSTOMER"
SortColumn = "A"
Case "FRAME NUMBER"
SortColumn = "B"
Case "MAKE"
SortColumn = "C"
Case "MODEL"
SortColumn = "D"
Case "ITEM BOUGHT"
SortColumn = "E"
Case "CHIP"
SortColumn = "F"
Case "COUNTRY"
SortColumn = "G"
Case "ORIGINAL PN"
SortColumn = "H"
Case "YEAR"
SortColumn = "I"
Case "LEAD"
SortColumn = "J"
Case "LEAD TYPE"
SortColumn = "K"
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
.Sort.SortFields.Clear
.Range("A7:K" & x).Sort Key1:=.Cells(7, SortColumn), Order1:=xlAscending, Header:=xlGuess
.Range("A8").Select
End With
End If
Unload AtoZMotorcycles
End Sub