Return to Previous sheet via Button

arnoldmo

New Member
Joined
Feb 23, 2011
Messages
9
Hope you can help. I am using 2003. I am using many pages in a workbook that uses buttons. I would now like the option to toggle to another page & then toggle back to my previous page, before exiting to the main contents page.

I only seem to have the capability (as I am new to this) to ask the buttons to go to specific pages. The below takes you to the information page, what code will I need to get back to my original page. I want to be able to enter to the imformation page from any of the 35 other pages, but I need it to remember what page I have just come from to take me back there.


Private Sub CommandButton9_Click()
'Application.ScreenUpdating = False
If MsgBox("Do you want to toggle to the additional information page? Click Yes to proceed and No to return", vbYesNo + vbCritical, "Toggle to Additional inforamtion page?") = vbNo Then Exit Sub
Sheet10.Select
'Application.ScreenUpdating = True
End Sub


Thanking you in advance of any help available x
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
NOT quite what I was after....
Thank you both for replying - However neither of your pages you have recommended have a code to suit what I need.

I need the information page to remember where I have just come from, so when I press the return to previous page button, it will take me there.
 
Upvote 0
Try:

Rich (BB code):
'    General Module
 
Public OldSheet As Worksheet
 
'    Existing code amended
 
Private Sub CommandButton9_Click()
    Application.ScreenUpdating = False
    If MsgBox("Do you want to toggle to the additional information page? Click Yes to proceed and No to return", vbYesNo + vbCritical, "Toggle to Additional inforamtion page?") = vbNo Then Exit Sub
    Set OldSheet = Me
    Sheet10.Select
    Application.ScreenUpdating = True
End Sub
 
'    CommandButton on Information worksheet
 
Private Sub CommandButton1_Click()
    On Error Resume Next
    OldSheet.Activate
End Sub
 
Upvote 0

Hi Andrew

for some reason that raised an error & did not work - the code I have provided takes you to the information page on sheet 10, I now need sheet 10 to take me back to where I have just come from via a button (Command button 4) . I could have originally come from any of hte 35 other sheets. I am so new to VB I do need simple steps.
Thanks
 
Upvote 0
I know what your existing code does and I know what you want.

What error do you get? Where did you put the code (see my comments before each section)?. The code worked when I tried it.
 
Upvote 0
Hi Andrew

sorry for being So thick.

I had no idea where to put the general module, however after many different erros I worked out it had to go on the top of the page befoer anyother coding - I put it on both sheets, then only on the original sheet.

I have amended my original code to what you have provided, Thank you.

I have placed the "information code" on the button code on the inforamtion sheet.

The button on the inforamtion sheet does not work when pressed. It does nothing.

NOt sure if its something I have done?

Regards

Arnoldmo
 
Upvote 0
The first line needs to go in a General module, like Module1, not in a worksheet module. If you don't have one choose Insert|Module from the menu.
 
Upvote 0
YAHOOOOOOOO!!!!!!!!! :laugh: it works!!


Thank you so much Andrew, I don't understand it all works, but it works and thats the main thing.

a BIG THANKS for sorting me out.
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,242
Members
452,898
Latest member
Capolavoro009

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