Easy one: Remembering previous sheet name

P

paul

Sheets EAST WEST NORTH and SOUTH all have a GO HOME button
that switches over to the HOME sheet. But from HOME, I
later need to get back to the sheet that sent me HOME, so
I need to remember the sheet name.

I tried AAA=Activesheet.Name as part of the GO HOME
button, then in HOME: Sheets(AAA).Select to take me back,
but that doesn't work.

TIA
Paul
 
K

keepitcool

you'll have to set the variable at the module level
so it will retain it's value between calls
(top of the module before the 1st procedure)


if all the code is in 1 module then

dim sSheetName as string

sub goHome()
ssheetname=activesheet.name
sheets(1).activate
end sub

sub goBack()
if ssheetname ="" then beep else sheets(ssheetname).activate
end sub


else put in 1 of the modules and refer to it with a qualifier so vba
knows where to find it.
also make it public if it's in an object module.


Public sSheetName as String

sheet1.ssheetname = activesheet.name


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
D

Dana DeLouis

Don't know if this would be of help. Would using the Web Toolbar "Back"
button work? If you customize your Excel Toolbar, it's under the "Web"
category. It may not be the best solution, but it appears to remember the
last Hyperlink jump (...If Hyperlinking to your Home sheet is what you are
doing).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top