Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Visual Basic

I wrote a simple macro which changes the value of cell "A1" on the first worksheet in a workbook which contains many worksheets. Obviously, I can execute the macro from any worksheet in the workbook. However, how do I modify the macro to RETURN to the specific worksheet I was in when I executed the macro, without specifying a specific sheet? In other words, I just want the macro to bring me back to whatever sheet I was in, when I executed the macro in the first place.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Visual Basic

when the code starts us
"set currentWorkSheet=Activeworkbook.ActiveSheet", so you can keep the reference
After you've done whatever you wanted d
currentWorkSheet.activat

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Visual Basic

Don't leave it.

That is

Worksheets(1).Range("A1").Value = "xx"

rather than

Worksheets(1).ACtivate
Range("A1").Value = "xx"

or (even worse)

Worksheets(1).ACtivate
Range("A1").Select
Selection.Value = "xx"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

" wrote in message
...
I wrote a simple macro which changes the value of cell "A1" on the first

worksheet in a workbook which contains many worksheets. Obviously, I can
execute the macro from any worksheet in the workbook. However, how do I
modify the macro to RETURN to the specific worksheet I was in when I
executed the macro, without specifying a specific sheet? In other words, I
just want the macro to bring me back to whatever sheet I was in, when I
executed the macro in the first place.


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
Is Visual Basic the same as Visual Studio 2008? Mike Stewart Excel Worksheet Functions 5 January 11th 09 04:58 PM
Visual Basic and SP2 JessJ Excel Discussion (Misc queries) 2 October 6th 05 12:17 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM
Visual Basic Micos3 Excel Discussion (Misc queries) 9 June 28th 05 01:41 PM
Visual Basic Todd[_7_] Excel Programming 3 September 10th 03 08:35 PM


All times are GMT +1. The time now is 07:13 AM.

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"