Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default run a macro on a certain action

I would like to run a macro when user selects a ceratin worksheet is this
possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default run a macro on a certain action

In the VBE, under the "Microsoft Excel Objects" in the Project Explorer,
you'll see the list of all worksheets in your workbook. Double-click on the
sheet for which you'd like the macro to apply then put your code in the
Worksheet_Activate procedu

Private Sub Worksheet_Activate()
Your code here
End Sub

Subsequently, whenever this worksheet is activated, your code will run.

"Jelinek" wrote:

I would like to run a macro when user selects a ceratin worksheet is this
possible?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default run a macro on a certain action

In the code module for the sheet:

Private Sub Worksheet_Activate()
'your code here
End Sub

HTH
knut

"Jelinek" skrev i melding
...
I would like to run a macro when user selects a ceratin worksheet is this
possible?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default run a macro on a certain action

Yes, that is what Event Procedures do - they are procedures that run when an
event occurs. What you want is the Workbook_SheetSelectionChange procedure.
If you go into the VBA editor, make sure the Project Explorer is visible
(from View menu if not). Then double click on the line that says
"ThisWorkbook." All the code that is specific to the workbook goes in there
and since the SheetSelectionChange is a Workbook based event you need to put
the code in that module.

Once you are in the module, in the code pane at the top will be two dropdown
lists. From the one on the left choose Workbook, then on the right choose
SheetSelectionChange. When you do this you will see the Sub declaration is
created:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Range)

End Sub
This is the sub that will run when you change the selected sheet(s); you
need to put your code in there. The parameters shown mean the the sheet
selected will be available to you in the variable Sh, the range that is
selected is available in the variable Target, so you can use these in your
code.

For more info look at VBA help or search this site for the words "Excel
Event Procedure."
--
- K Dales


"Jelinek" wrote:

I would like to run a macro when user selects a ceratin worksheet is this
possible?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default run a macro on a certain action

Another source of information on events

Chip Pearson's site
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy


"Jelinek" wrote in message
...
I would like to run a macro when user selects a ceratin worksheet is this
possible?



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 to action formula pvkutty New Users to Excel 1 February 13th 10 02:01 PM
Excell copy action pauses for 15 second for the smallest action Meekal Excel Discussion (Misc queries) 1 January 28th 10 04:30 PM
on particular action run a macro Jelinek Excel Discussion (Misc queries) 1 February 3rd 06 01:21 PM
REPEAT SOME ACTION IN MACRO SURESH Excel Programming 2 July 4th 05 02:05 PM
Running a macro on action Andrew Excel Programming 5 April 6th 05 08:05 AM


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