web-style back button

lpking2005

Board Regular
Joined
Mar 21, 2011
Messages
140
hi,

im in need of some help...

I have a workbook which contains alot of sheets, i have a Back button and home button at the top of each sheet.

Im having trouble finding a way of making the back button remember the previous selected sheets so the user can always go back to the previous sheet they came from.

Ive found some thing on various forums but nothing works very well.

I did find something which looked promising, but i get an error when the code runs.
This uses the back button from the "web" Commandbar:
Code:
Application.CommandBars.FindControl(ID:=1017).Execute ' Back

any help would be appreciated!
thanks!
 
I have run into a problem with the code.

When the workbook opens, it fails on the following line of code:

Code:
History.Add Sh

the error is:

run time error '91'
object variable or with block variable not set.
 
Upvote 0

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
That's odd, it works fine for me. That error would suggest that the History object has not been instantiated. Is your code exactly as I suggested? One thing I don't understand is this. The line that is failing is in the Workbook_SheetActivate procedure but this shouldn't run when you open the workbook, unless your Workbook_Open is also activating another sheet.

Cheers

Gordon
 
Upvote 0
ive noticed that the error only happens when i adjust some code somewhere else or i manually save the workbook.

I have to go back and run the workbook_open code again manually to be able to fix it.

:confused::confused::confused:
 
Upvote 0
As I put in an earlier message

"The History collection holds the list of sheets you've visited in order. It gets instantiated when you open the workbook. If you are testing and already have the workbook open it won't have been instantiated and will fail. All you need to do is run the Workbook_Open procedure ie put your cursor in it and press F5."

So if you have to alter the code while your developing your workbook you will have to run the Workbook_Open procedure, as you've found. As long as you've run the Workbook_Open procedure either manually or as part of opening the workbook then it should work fine. Using the tabs is how I tested it so that should not be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top