ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a back key (https://www.excelbanter.com/excel-programming/326976-creating-back-key.html)

Kevin Smith[_4_]

Creating a back key
 
Hi all,

I wish to be able to grab the sheet name so the user can return to that
sheet from another.
For example, if I go from sheet 3 to sheet 1, hiting "back" will take me
back to sheet 3. If I go from sheet 2 to sheet 1, hitting "back" will take me
back to sheet 2.

I have a lookup file that users will edit then return to the previous screen
to see the impact of their changes.

Many thanks

Kevin

keepITcool

Creating a back key
 
...

in thisworkbook code module:

Dim lastindex As Long

Public Sub DoBack()
Worksheets(lastindex).Activate
End Sub

Private Sub Workbook_Open()
lastindex = ActiveSheet.Index
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
lastindex = Sh.Index
End Sub

then in macro options assign CTRL-B to DoBack
i think the shortcut is easier then a button...




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Kevin Smith wrote :

Hi all,

I wish to be able to grab the sheet name so the user can return to
that sheet from another.
For example, if I go from sheet 3 to sheet 1, hiting "back" will take
me back to sheet 3. If I go from sheet 2 to sheet 1, hitting "back"
will take me back to sheet 2.

I have a lookup file that users will edit then return to the previous
screen to see the impact of their changes.

Many thanks

Kevin



All times are GMT +1. The time now is 10:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com