'Go Back' Button or Macro

lmpowell

New Member
Joined
Sep 20, 2006
Messages
5
Does anyone know of a back button in Excel 2003? I have several cells that are assigned a macro that will display a hidden worksheet. I want some kind of a 'back' feature that will return the user to the cell (which varies) that they were in before running the macro.

For example, macro A is assigned to cells A21, B24, and C143 in worksheet 1. If the user is in cell B24 of worksheet 1 and runs the macro which takes the user to worksheet 2, I want a 'back' feature (button or macro) that will return the user to cell B24 in worksheet 1 (or cell A21 if the user was in cell A21, etc).

Thanks!
LaDonn
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Does anyone know of a back button in Excel 2003? I have several cells that are assigned a macro that will display a hidden worksheet. I want some kind of a 'back' feature that will return the user to the cell (which varies) that they were in before running the macro.

For example, macro A is assigned to cells A21, B24, and C143 in worksheet 1. If the user is in cell B24 of worksheet 1 and runs the macro which takes the user to worksheet 2, I want a 'back' feature (button or macro) that will return the user to cell B24 in worksheet 1 (or cell A21 if the user was in cell A21, etc).

Thanks!
LaDonn
Hi

If you don't use Select/Activate, it should stay in the same cell.
 
Upvote 0
Hello lmpowell,
What jindon says is true and is ultimately the best way to try to code your routines if
possible, however if that's not possible for some reason (hard to imagine but what
the heck...) then here's a rather cheesy but effective way to get your 'back button'.

At the top of a standard module type (or paste) this.
Code:
Public SheetToReturnTo As Worksheet
Public CellToReturnTo As Range
Then in all your different macros, add this at the top of your code (or anywhere
before any activating/selecting takes place.)
Code:
Set SheetToReturnTo = ActiveSheet
Set CellToReturnTo = ActiveCell
Finally, for your back button's code you can use this.
Code:
Sub BackButton()
SheetToReturnTo.Select
CellToReturnTo.Select
Set SheetToReturnTo = Nothing
Set CellToReturnTo = Nothing
End Sub
Like I said, this should work fine but if you can I would seriously recommend
trying to code your routines without activating/selecting to begin with.
 
Upvote 0

Forum statistics

Threads
1,214,634
Messages
6,120,659
Members
448,975
Latest member
sweeberry

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