Macro to go back to last used sheet

J

johan

Hello,

Can somebody help me. I need a macro that activate the forelast used
sheet.

For example: I had done something in sheet 1 and then I jump to sheet
5.
I do some editing in sheet 5 and when I click on the "go back" button
I want automatic jump back to the forelast activated sheet (in this
case sheet 1).

Is there a solution.

regards and thanks,
Johan
 
J

jgrob3

Hello,

Can somebody help me. I need a macro that activate the forelast used
sheet.

For example: I had done something in sheet 1 and then I jump to sheet
5.
I do some editing in sheet 5 and when I click on the "go back" button
I want automatic jump back to the forelast activated sheet (in this
case sheet 1).

Is there a solution.

regards and thanks,
Johan

Johan,

I can't think of an easy way to achieve this since Excel doesn't track
user movements around a workbook in the same way as Internet Explorer
does.

One way to achieve this however would be to put a small piece of code
under the Worksheet_Activate() event on each of your worksheets. The
code could call a public sub eg StoreSheetName which would store the
name of each sheet in a table somewhere.

Then, when your user clicks "Back", you'd link this to a macro which
looks up the 2nd last row of your table. If you only need your "Back"
button to work once, you'd clear the data table at that point, then go
to the sheet name from the 2nd last row.

If you need your "Back" button to work more than once, you'd clear
everything from the 2nd last row onwards (inclusive) then go to the
sheet.

regards

Jeff
 

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