PDA

View Full Version : Solved: how to do BACK (in workbook between sheets)



danovkos
05-21-2010, 05:27 AM
Hi all,
Pls. i have a lot of sheets in my workbook. I try to figured out, how to do BACK function between sheets. I mean, when i am in sheet 2 and swtich to sheet 3 then i press e.g. key F6 and it swich back to sheet 2.

Is here any easy way, how to do it?
I think it can works something like. If sheets is changing (when i leave e.g. sheet "3" it will write name of this sheet to some existing sheet in wb(e.g. to sheet "data" in cell B1 - this can be always allocated for this function). And then any macro will look here and after pressing F6 it activate sheet from cell B1.

I use key mapping like this:

Application.OnKey "{TAB}", "GoToTextBox"

but i dont know how to do - after sheets leaving wrote name of sheet to B1...

thx a lot for help

adamsm
05-21-2010, 05:55 AM
Try the attached & let me know your response

mdmackillop
05-21-2010, 07:40 AM
Hi adamsm
Right click the navigation buttons to the left of the tabs.

mdmackillop
05-21-2010, 08:06 AM
In a Standard Module

Option Explicit
Public LastSheet As Worksheet

Sub GoToLast()
LastSheet.Activate
End Sub



in ThisWorkbook module



Option Explicit
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Set LastSheet = Sh
End Sub



Create a shortcut to GoToLast

adamsm
05-21-2010, 11:52 PM
Thanks MD

danovkos
05-23-2010, 11:01 PM
thx to all,
adamsm: your code looks good, but i think it doesnt works as i mean.

mdmackillop: your code works as usuall - PERFECT :)
THX A LOT TO ALL M8s
:):rotlaugh: :clap: