Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Returning to a previous location

In my workbook I have created some sheets that are used for special
calculations which I have hidden because they are not always needed (and I
don't know how to make a VBA message box that will handle the calculations).
I have managed to open a hidden sheet and close it when done but I wind up
on the last visible sheet and I want to go back where I started. I have
tried numerous ways but without success. Can any one help me out.

TIA Steve H


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Returning to a previous location

Steve,

Try something like the following:

Dim SaveTLC As Range
Dim SaveSelection As Range

Sub SaveLocation()
Set SaveTLC = ActiveWindow.VisibleRange(1, 1)
Set SaveSelection = Selection
End Sub
Sub ReturnLocation()
Application.Goto SaveTLC, True
Application.Goto SaveSelection, False
End Sub

Call the SaveLocation procedure prior to executing your code, and then call
ReturnLocation after your code is finished to return to the original
location.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


wrote in message
...
In my workbook I have created some sheets that are used for special
calculations which I have hidden because they are not always needed (and I
don't know how to make a VBA message box that will handle the

calculations).
I have managed to open a hidden sheet and close it when done but I wind up
on the last visible sheet and I want to go back where I started. I have
tried numerous ways but without success. Can any one help me out.

TIA Steve H




  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Returning to a previous location

Works like a champ! Thanks, Chip.

Steve

"Chip Pearson" wrote in message
...
Steve,

Try something like the following:

Dim SaveTLC As Range
Dim SaveSelection As Range

Sub SaveLocation()
Set SaveTLC = ActiveWindow.VisibleRange(1, 1)
Set SaveSelection = Selection
End Sub
Sub ReturnLocation()
Application.Goto SaveTLC, True
Application.Goto SaveSelection, False
End Sub

Call the SaveLocation procedure prior to executing your code, and then

call
ReturnLocation after your code is finished to return to the original
location.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


wrote in message
...
In my workbook I have created some sheets that are used for special
calculations which I have hidden because they are not always needed (and

I
don't know how to make a VBA message box that will handle the

calculations).
I have managed to open a hidden sheet and close it when done but I wind

up
on the last visible sheet and I want to go back where I started. I have
tried numerous ways but without success. Can any one help me out.

TIA Steve H






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
3-Color Scale Vlookup for Current Month/Previous/Pre-Previous NeoFax Excel Discussion (Misc queries) 2 January 8th 10 07:04 PM
Hyperlink or Other Method To Return To Previous Location (Sheet) Possible? Mhz New Users to Excel 4 August 1st 06 11:39 AM
Returning To Previous Worksheet - Help with sebastienm's code AcesUp Excel Discussion (Misc queries) 0 June 3rd 06 12:47 PM
shortcut to go to previous location or cell Jan Excel Discussion (Misc queries) 2 November 14th 05 11:08 AM
Finding data in a Range / Returning Cell Location Betsy Jones Excel Programming 2 August 8th 03 10:10 PM


All times are GMT +1. The time now is 06:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"