Link to home
Start Free TrialLog in
Avatar of Maniac3575
Maniac3575Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Excel - Returning Focus after calling a macro

I have a simple macro (a sort table routine) that is called upon any change on the spreadshett. However once the macro is called, focus is transferred to those cells, and I would like to return focus to the cell that was amended. Any ideas ?

Regards,
Andy

The routine for checking the change is as follows:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        table
End Sub

And the sort is as follows:

Sub table()
    Range("Q3:V9").Select
    Selection.Sort Key1:=Range("V4"), Order1:=xlDescending, Key2:=Range("U4") _
        , Order2:=xlDescending, Key3:=Range("S4"), Order3:=xlDescending, Header _
        :=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:= _
        xlSortNormal
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Brian Mulder
Brian Mulder
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Maniac3575

ASKER

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
 call table
 target.activate
End Sub


Works for me, many thanks
you're welcome, didn't know for sure if the sort would trigger the event....thanks for the points