Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Inserting code to call a routine when creating a worksheet

I have a macro that creates a new sheet from a template. Once the new sheet
is set up, I need to add a Call to another macro every time the sheet is
selected by the user so that the sheet can be populated w/ current info.

How & to where do I copy a short routine to do this call?

What is the form of the Sub stmt that executes only when the user selects
the worksheet tab and not when other activity takes place on the sheet?

I appreciate your help, -John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Inserting code to call a routine when creating a worksheet

One way:

Put this in the worksheet code module:

Private Sub Worksheet_Activate()
Call MyUpdateMacro
End Sub


In article ,
John wrote:

I have a macro that creates a new sheet from a template. Once the new sheet
is set up, I need to add a Call to another macro every time the sheet is
selected by the user so that the sheet can be populated w/ current info.

How & to where do I copy a short routine to do this call?

What is the form of the Sub stmt that executes only when the user selects
the worksheet tab and not when other activity takes place on the sheet?

I appreciate your help, -John

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Inserting code to call a routine when creating a worksheet

This helps a lot. Now, what code do I use to copy these three lines into the
place where it needs to go after I create the worksheet so it gets executed
when the worksheet is selected?

"JE McGimpsey" wrote:

One way:

Put this in the worksheet code module:

Private Sub Worksheet_Activate()
Call MyUpdateMacro
End Sub


In article ,
John wrote:

I have a macro that creates a new sheet from a template. Once the new sheet
is set up, I need to add a Call to another macro every time the sheet is
selected by the user so that the sheet can be populated w/ current info.

How & to where do I copy a short routine to do this call?

What is the form of the Sub stmt that executes only when the user selects
the worksheet tab and not when other activity takes place on the sheet?

I appreciate your help, -John


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Inserting code to call a routine when creating a worksheet

What code are you using to create the new sheet?

"John" wrote:

This helps a lot. Now, what code do I use to copy these three lines into the
place where it needs to go after I create the worksheet so it gets executed
when the worksheet is selected?

"JE McGimpsey" wrote:

One way:

Put this in the worksheet code module:

Private Sub Worksheet_Activate()
Call MyUpdateMacro
End Sub


In article ,
John wrote:

I have a macro that creates a new sheet from a template. Once the new sheet
is set up, I need to add a Call to another macro every time the sheet is
selected by the user so that the sheet can be populated w/ current info.

How & to where do I copy a short routine to do this call?

What is the form of the Sub stmt that executes only when the user selects
the worksheet tab and not when other activity takes place on the sheet?

I appreciate your help, -John


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Inserting code to call a routine when creating a worksheet

If OP simply copies the sheet, the code will go with it.


Gord Dibben MS Excel MVP

On Thu, 5 Feb 2009 10:51:36 -0800, JLGWhiz
wrote:

What code are you using to create the new sheet?

"John" wrote:

This helps a lot. Now, what code do I use to copy these three lines into the
place where it needs to go after I create the worksheet so it gets executed
when the worksheet is selected?

"JE McGimpsey" wrote:

One way:

Put this in the worksheet code module:

Private Sub Worksheet_Activate()
Call MyUpdateMacro
End Sub


In article ,
John wrote:

I have a macro that creates a new sheet from a template. Once the new sheet
is set up, I need to add a Call to another macro every time the sheet is
selected by the user so that the sheet can be populated w/ current info.

How & to where do I copy a short routine to do this call?

What is the form of the Sub stmt that executes only when the user selects
the worksheet tab and not when other activity takes place on the sheet?

I appreciate your help, -John




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Inserting code to call a routine when creating a worksheet

I know, my question was rhetorical. <g

"Gord Dibben" wrote:

If OP simply copies the sheet, the code will go with it.


Gord Dibben MS Excel MVP

On Thu, 5 Feb 2009 10:51:36 -0800, JLGWhiz
wrote:

What code are you using to create the new sheet?

"John" wrote:

This helps a lot. Now, what code do I use to copy these three lines into the
place where it needs to go after I create the worksheet so it gets executed
when the worksheet is selected?

"JE McGimpsey" wrote:

One way:

Put this in the worksheet code module:

Private Sub Worksheet_Activate()
Call MyUpdateMacro
End Sub


In article ,
John wrote:

I have a macro that creates a new sheet from a template. Once the new sheet
is set up, I need to add a Call to another macro every time the sheet is
selected by the user so that the sheet can be populated w/ current info.

How & to where do I copy a short routine to do this call?

What is the form of the Sub stmt that executes only when the user selects
the worksheet tab and not when other activity takes place on the sheet?

I appreciate your help, -John



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Inserting code to call a routine when creating a worksheet

I thought yours was a valid question and my comment was really for the OP.

Should have posted a reply there instead.


Gord




On Thu, 5 Feb 2009 15:40:34 -0800, JLGWhiz
wrote:

I know, my question was rhetorical. <g

"Gord Dibben" wrote:

If OP simply copies the sheet, the code will go with it.


Gord Dibben MS Excel MVP

On Thu, 5 Feb 2009 10:51:36 -0800, JLGWhiz
wrote:

What code are you using to create the new sheet?

"John" wrote:

This helps a lot. Now, what code do I use to copy these three lines into the
place where it needs to go after I create the worksheet so it gets executed
when the worksheet is selected?

"JE McGimpsey" wrote:

One way:

Put this in the worksheet code module:

Private Sub Worksheet_Activate()
Call MyUpdateMacro
End Sub


In article ,
John wrote:

I have a macro that creates a new sheet from a template. Once the new sheet
is set up, I need to add a Call to another macro every time the sheet is
selected by the user so that the sheet can be populated w/ current info.

How & to where do I copy a short routine to do this call?

What is the form of the Sub stmt that executes only when the user selects
the worksheet tab and not when other activity takes place on the sheet?

I appreciate your help, -John




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Inserting code to call a routine when creating a worksheet

Gord, thank you for your response. It answered my question. It hadn't dawned
on me that the code would copy with the copy of the sheet- I thought I had to
recreate it on the new worksheet.

Frankly, coming from my frame of mind, I felt JLGWhiz's response was a
little sarcastic and unhelpful. But it is always difficult to read someone's
frame of mind via just a short post on the internet.

Thx again, John

"Gord Dibben" wrote:

I thought yours was a valid question and my comment was really for the OP.

Should have posted a reply there instead.


Gord




On Thu, 5 Feb 2009 15:40:34 -0800, JLGWhiz
wrote:

I know, my question was rhetorical. <g

"Gord Dibben" wrote:

If OP simply copies the sheet, the code will go with it.


Gord Dibben MS Excel MVP

On Thu, 5 Feb 2009 10:51:36 -0800, JLGWhiz
wrote:

What code are you using to create the new sheet?

"John" wrote:

This helps a lot. Now, what code do I use to copy these three lines into the
place where it needs to go after I create the worksheet so it gets executed
when the worksheet is selected?

"JE McGimpsey" wrote:

One way:

Put this in the worksheet code module:

Private Sub Worksheet_Activate()
Call MyUpdateMacro
End Sub


In article ,
John wrote:

I have a macro that creates a new sheet from a template. Once the new sheet
is set up, I need to add a Call to another macro every time the sheet is
selected by the user so that the sheet can be populated w/ current info.

How & to where do I copy a short routine to do this call?

What is the form of the Sub stmt that executes only when the user selects
the worksheet tab and not when other activity takes place on the sheet?

I appreciate your help, -John





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
Sub Routine Call From a Macro D. Jones Excel Discussion (Misc queries) 1 November 8th 07 11:01 PM
How can I create a worksheet in a routine and set the code name at kataiwo Excel Programming 2 September 16th 06 04:12 PM
How to keep a Variable alive after a Call to Sub Routine Dennis Excel Discussion (Misc queries) 2 July 27th 05 10:57 PM
How to call a VBA routine in an add-in from a VB app? Camden Excel Programming 1 November 1st 04 05:17 PM
Call MS Word envelope printing routine? Richard[_28_] Excel Programming 0 April 27th 04 09:08 PM


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