Scroll to selected cell after code has run

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,983
Office Version
  1. 2007
Platform
  1. 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

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
 

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top