Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to end macro on inital active worksheet containing macro button that was clicked

I developed a formating macro that can be run by clicking a button on anyone of 20 worksheets. Currently the macro always ends on the 20th worksheet. How can I get the macro to return me to the worksheet I was on when the macro was activated?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to end macro on inital active worksheet containing macro button that was clicked


Set shFirst = Activesheet
'do your bit
shFirts.Activate

--

HTH

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

"Silverhawk1" wrote in message
...
I developed a formating macro that can be run by clicking a button on

anyone of 20 worksheets. Currently the macro always ends on the 20th
worksheet. How can I get the macro to return me to the worksheet I was on
when the macro was activated?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default How to end macro on inital active worksheet containing macro button that was clicked

Hi Silverhawk1

For most of the things you don't have to select the sheets in the loop.
Then your sheet stay active.

But if you must select then you can use this

Sub test()
Dim Asheet As Worksheet
Set Asheet = ActiveSheet

' your code


Asheet.Select
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Silverhawk1" wrote in message ...
I developed a formating macro that can be run by clicking a button on anyone of 20 worksheets. Currently the macro always ends on

the 20th worksheet. How can I get the macro to return me to the worksheet I was on when the macro was activated?


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
Macro button gets bigger when clicked Snowskier Excel Discussion (Misc queries) 1 May 27th 10 09:36 PM
Button macro to move/delete active row KevHardy Excel Discussion (Misc queries) 4 February 13th 10 11:59 AM
Change Macro button color after clicked Cong Nguyen Excel Discussion (Misc queries) 2 November 30th 07 02:55 PM
Need to identify active worksheet in macro MLK Excel Worksheet Functions 1 March 13th 07 04:29 PM
Macro to increase cell value by 1 each time button clicked fozzer[_2_] Excel Programming 2 April 29th 04 01:58 PM


All times are GMT +1. The time now is 06:46 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"