Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Run a macro when a Worksheet is clicked/activated

Hi,

I'm looking for code that runs a macro when a worksheet called "email" is
clicked everytime. I think it's an event macro, but, I can not seem to find
an example.

The macro I want to run is simple

Sheets("email").Select
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1

Thanks in advance.

Wazza McG


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Run a macro when a Worksheet is clicked/activated

Rightclick on the Email sheet tab and select "View Code".

From the drop down boxes above select Worksheet (from the left) and
Activate (from the right). This should create a procedure for you thus:

Private Sub Worksheet_Activate()

End Sub

Insert your code here in there e.g.

Private Sub Worksheet_Activate()
msgbox "I'm clicked"
End Sub

It will then fire every time the worksheet is activated. If that
Activates isn't what you're after, try Worksheet_SelectionChange or
maybe a combination of the two.

HTH,
Gareth

Warren McGoldrick wrote:
Hi,

I'm looking for code that runs a macro when a worksheet called "email" is
clicked everytime. I think it's an event macro, but, I can not seem to find
an example.

The macro I want to run is simple

Sheets("email").Select
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1

Thanks in advance.

Wazza McG


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run a macro when a Worksheet is clicked/activated

Thankyou Thankyou Thankyou
Gee that was simple!
Much appreciated, I have never used those View Code sheets before - great
stuff.

Wazza McG




"Gareth" wrote in message
...
Rightclick on the Email sheet tab and select "View Code".

From the drop down boxes above select Worksheet (from the left) and
Activate (from the right). This should create a procedure for you thus:

Private Sub Worksheet_Activate()

End Sub

Insert your code here in there e.g.

Private Sub Worksheet_Activate()
msgbox "I'm clicked"
End Sub

It will then fire every time the worksheet is activated. If that Activates
isn't what you're after, try Worksheet_SelectionChange or maybe a
combination of the two.

HTH,
Gareth

Warren McGoldrick wrote:
Hi,

I'm looking for code that runs a macro when a worksheet called "email" is
clicked everytime. I think it's an event macro, but, I can not seem to
find an example.

The macro I want to run is simple

Sheets("email").Select
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1

Thanks in advance.

Wazza McG



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 158
Default Run a macro when a Worksheet is clicked/activated

You're welcome!

Wazza McG wrote:
Thankyou Thankyou Thankyou
Gee that was simple!
Much appreciated, I have never used those View Code sheets before - great
stuff.

Wazza McG




"Gareth" wrote in message
...

Rightclick on the Email sheet tab and select "View Code".

From the drop down boxes above select Worksheet (from the left) and
Activate (from the right). This should create a procedure for you thus:

Private Sub Worksheet_Activate()

End Sub

Insert your code here in there e.g.

Private Sub Worksheet_Activate()
msgbox "I'm clicked"
End Sub

It will then fire every time the worksheet is activated. If that Activates
isn't what you're after, try Worksheet_SelectionChange or maybe a
combination of the two.

HTH,
Gareth

Warren McGoldrick wrote:

Hi,

I'm looking for code that runs a macro when a worksheet called "email" is
clicked everytime. I think it's an event macro, but, I can not seem to
find an example.

The macro I want to run is simple

Sheets("email").Select
Range("A1").Select
Application.CutCopyMode = False
ActiveWindow.ScrollRow = 1
ActiveWindow.ScrollColumn = 1

Thanks in advance.

Wazza McG




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 ACTIVATED AYTOMATICALLY Spiros Excel Discussion (Misc queries) 0 June 12th 08 07:25 AM
MACRO ACTIVATED EVERY 5 SECONDS CC Excel Discussion (Misc queries) 1 May 4th 06 03:02 PM
User Form activated by a macro mxleite Excel Programming 3 July 3rd 04 01:33 AM
How to end macro on inital active worksheet containing macro button that was clicked Silverhawk1 Excel Programming 2 May 14th 04 03:58 PM
Is there a way to know when a worksheet has been clicked? John[_35_] Excel Programming 3 July 28th 03 10:05 PM


All times are GMT +1. The time now is 06:12 PM.

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"