Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return to current worksheet
I have a macro which when it runs cycle through all the worksheets in my
workbook. When it finishes it leaves me on the last worksheet of the workbook. I would like to be returned to the worksheet that was active when the macro was started. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return to current worksheet
Sub GoBackHomeDemo()
Dim sh as Worksheet, sh1 as Worksheet set sh1 = Activesheet for each sh in Worksheets sh.Activate Next sh1.Activate End Sub -- Regards, Tom Ogilvy "Patrick Simonds" wrote: I have a macro which when it runs cycle through all the worksheets in my workbook. When it finishes it leaves me on the last worksheet of the workbook. I would like to be returned to the worksheet that was active when the macro was started. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Return to current worksheet
Define a variable as a string to capture your macro workbook name
Dim MainWB as string MainWB=ActiveWorkbook.Name 'place this somewhere near the beginning of your macro ......after sub runs, near end of macro Windows(MainWB).Activate ....for more specifics, you could also add the following Sheets("insertSheetNameHere").Select Range("A1").Select ---Joran6 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
return the current row number for use in a formula | Excel Discussion (Misc queries) | |||
use the current time to return a value | Excel Discussion (Misc queries) | |||
use the current time to return a value | Excel Programming | |||
Function to return the current Worksheet name? | Excel Worksheet Functions | |||
Return number of current sheet | Excel Worksheet Functions |