#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Worksheets

Hello,
Is it possible to create a macro or VBA to return to the previous sheet
(the one I just left, not the one next to it)? I leave the sheet to open a
different one and then want to quickly return to the first.Does that make
sense?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Worksheets

Explain the part about "leaving the sheet to open a different one"...
exactly what are you doing there and show the code you are using to do it?

--
Rick (MVP - Excel)


"Rope" wrote in message
...
Hello,
Is it possible to create a macro or VBA to return to the previous sheet
(the one I just left, not the one next to it)? I leave the sheet to open a
different one and then want to quickly return to the first.Does that make
sense?


  #3   Report Post  
Posted to microsoft.public.excel.programming
Member
 
Location: In a hole in the ground there lived Joshua Fandango
Posts: 30
Default Worksheets

Hi Rope,

Bit of an ambiguous question; do you want to prevent a user selecting
a different sheet?
The following makes Sheet1 the active sheet whenever another sheet is
selected when you put the code in the Sheet1(Sheet1) module:

Option Explicit
Private Sub Worksheet_Deactivate()
Sheet1.Activate
End Sub

HtH,
JF.



On 19 Dec, 00:41, Rope wrote:
Hello,
* Is it possible to create a macro or VBA to return to the previous sheet
(the one I just left, not the one next to it)? I leave the sheet to open a
different one and then want to quickly return to the first.Does that make
sense?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Worksheets

Hi,
Thanks for the response. I knew that explanation was vague. What I am
trying to do is as follows: I am working on an active worksheet entering
data, I use a macro to jump to a another specific worksheet that contains
embedded forms that cover all the worksheets (memory limitations). After I
complete and print the form, I would like to bounce back to the same
worksheet I was entering the data into originally to complete anything else
that needs to be done. It would be nice to use a code/macro that brings me
back to the worksheet without having to search for it by using the horizontal
scroll bar (I have "alot" of sheets in this workbook). I hope that explains
my situation. I appreciate your assistance.
Rope

"Joshua Fandango" wrote:

Hi Rope,

Bit of an ambiguous question; do you want to prevent a user selecting
a different sheet?
The following makes Sheet1 the active sheet whenever another sheet is
selected when you put the code in the Sheet1(Sheet1) module:

Option Explicit
Private Sub Worksheet_Deactivate()
Sheet1.Activate
End Sub

HtH,
JF.



On 19 Dec, 00:41, Rope wrote:
Hello,
Is it possible to create a macro or VBA to return to the previous sheet
(the one I just left, not the one next to it)? I leave the sheet to open a
different one and then want to quickly return to the first.Does that make
sense?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Worksheets

Hi

Maybe something like this:

Sub AAA()
OrgSheet=activesheet.name

'Your code

Sheets(OrgSheet).activage

End Sub

Regards,
Per

On 19 Dec., 16:08, Rope wrote:
Hi,
* Thanks for the response. *I knew that explanation was vague. *What I am
trying to do is as follows: *I am working on an active worksheet entering
data, I use a macro to jump to a another specific worksheet that contains
embedded forms that cover all the worksheets (memory limitations). *After I
complete and print the form, I would like to bounce back to the same
worksheet I was entering the data into originally to complete anything else
that needs to be done. *It would be nice to use a code/macro that brings me
back to the worksheet without having to search for it by using the horizontal
scroll bar (I have "alot" of sheets in this workbook). *I hope that explains
my situation. *I appreciate your assistance.
Rope



"Joshua Fandango" wrote:
Hi Rope,


Bit of an ambiguous question; do you want to prevent a user selecting
a different sheet?
The following makes Sheet1 the active sheet whenever another sheet is
selected when you put the code in the Sheet1(Sheet1) module:


Option Explicit
Private Sub Worksheet_Deactivate()
* Sheet1.Activate
End Sub


HtH,
JF.


On 19 Dec, 00:41, Rope wrote:
Hello,
* Is it possible to create a macro or VBA to return to the previous sheet
(the one I just left, not the one next to it)? I leave the sheet to open a
different one and then want to quickly return to the first.Does that make
sense?- Skjul tekst i anførselstegn -


- Vis tekst i anførselstegn -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Worksheets

In a regular code module name Module1, use

Public PrevSheet As Worksheet

Sub GoBack()
PrevSheet.Select
End Sub

Then in the ThisWorkbook module, use

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
Set Module1.PrevSheet = Sh
End Sub

This allows only one level of going back. When you run GoBack (you can
assign it to a keyboard shortcut if you want), you will go to the
previously selected sheet.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Thu, 18 Dec 2008 16:41:01 -0800, Rope
wrote:

Hello,
Is it possible to create a macro or VBA to return to the previous sheet
(the one I just left, not the one next to it)? I leave the sheet to open a
different one and then want to quickly return to the first.Does that make
sense?

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
Creating new worksheets and appending data from multiple worksheets. Dow Excel Programming 5 March 11th 08 07:04 PM
Compare Rows on different Worksheets and Output Difference's to other Worksheets. [email protected] Excel Programming 3 September 19th 07 04:48 PM
How use info in Excel shared worksheets to create new worksheets dkc Excel Worksheet Functions 0 June 28th 07 08:36 PM
VBA / Macro for creating new worksheets and new columns from existing worksheets webby2006 Excel Programming 3 July 25th 06 03:38 PM
Need code to protect worksheets - amount of worksheets varies Sandy[_3_] Excel Programming 1 September 9th 03 02:17 AM


All times are GMT +1. The time now is 08:45 PM.

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

About Us

"It's about Microsoft Excel"