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

I have an excel spread sheet that I use as a template. When this template
opens, I have a userform that pops up and asks the user to select one of 2
options.

Option 2 is to enable the user to perform maintenence or updates on the
template.

Option 1 saves the worksheet tabs of the template to a new book and saves
the new book as a specified file name. note: I am saving the worksheet tabs
because I do not want the modules to copy to the new file, just the tabs and
any code on the worksheet tabs.

Now comes my problem. 2 of the worksheet tabs that has macro code on them
has a button on the same worksheet that the code is in and the macro code is
assigned to the button. When the save process occurs, the assignment of the
macro does not stay with the button. Instead the assignment is pointed back
to the template, instead of staying assigned to the code found on the
worksheet.
How can I make the macro assignment stay pointing to the code of the
worksheet the button is found on even if the tab is copied to a new workbook?

Thanks for any help.
--
Stephen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Assigned Macro to button

Hi Stephen

Use a button from the Control ToolBox(ActiveX) instead of a Forms button

This button have a click event in the sheet module and when you copy the sheet it
will copy this also to the new workbook

Private Sub CommandButton1_Click()
'enter your code here
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
I have an excel spread sheet that I use as a template. When this template
opens, I have a userform that pops up and asks the user to select one of 2
options.

Option 2 is to enable the user to perform maintenence or updates on the
template.

Option 1 saves the worksheet tabs of the template to a new book and saves
the new book as a specified file name. note: I am saving the worksheet tabs
because I do not want the modules to copy to the new file, just the tabs and
any code on the worksheet tabs.

Now comes my problem. 2 of the worksheet tabs that has macro code on them
has a button on the same worksheet that the code is in and the macro code is
assigned to the button. When the save process occurs, the assignment of the
macro does not stay with the button. Instead the assignment is pointed back
to the template, instead of staying assigned to the code found on the
worksheet.
How can I make the macro assignment stay pointing to the code of the
worksheet the button is found on even if the tab is copied to a new workbook?

Thanks for any help.
--
Stephen


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Assigned Macro to button

Thank you for the prompt reply. I did your suggestion but the ActiveX Button
will not allow me to click on it to run the code. When I click on it I get
the sizing bubbles around the button. How do I get it to allow me to click on
it?
--
Stephen


"Ron de Bruin" wrote:

Hi Stephen

Use a button from the Control ToolBox(ActiveX) instead of a Forms button

This button have a click event in the sheet module and when you copy the sheet it
will copy this also to the new workbook

Private Sub CommandButton1_Click()
'enter your code here
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
I have an excel spread sheet that I use as a template. When this template
opens, I have a userform that pops up and asks the user to select one of 2
options.

Option 2 is to enable the user to perform maintenence or updates on the
template.

Option 1 saves the worksheet tabs of the template to a new book and saves
the new book as a specified file name. note: I am saving the worksheet tabs
because I do not want the modules to copy to the new file, just the tabs and
any code on the worksheet tabs.

Now comes my problem. 2 of the worksheet tabs that has macro code on them
has a button on the same worksheet that the code is in and the macro code is
assigned to the button. When the save process occurs, the assignment of the
macro does not stay with the button. Instead the assignment is pointed back
to the template, instead of staying assigned to the code found on the
worksheet.
How can I make the macro assignment stay pointing to the code of the
worksheet the button is found on even if the tab is copied to a new workbook?

Thanks for any help.
--
Stephen



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Assigned Macro to button

Double click on the button and it will open the VBA editor with the click event
Add your code
Close the editor
Click the Design mode button

Test it


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
Thank you for the prompt reply. I did your suggestion but the ActiveX Button
will not allow me to click on it to run the code. When I click on it I get
the sizing bubbles around the button. How do I get it to allow me to click on
it?
--
Stephen


"Ron de Bruin" wrote:

Hi Stephen

Use a button from the Control ToolBox(ActiveX) instead of a Forms button

This button have a click event in the sheet module and when you copy the sheet it
will copy this also to the new workbook

Private Sub CommandButton1_Click()
'enter your code here
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
I have an excel spread sheet that I use as a template. When this template
opens, I have a userform that pops up and asks the user to select one of 2
options.

Option 2 is to enable the user to perform maintenence or updates on the
template.

Option 1 saves the worksheet tabs of the template to a new book and saves
the new book as a specified file name. note: I am saving the worksheet tabs
because I do not want the modules to copy to the new file, just the tabs and
any code on the worksheet tabs.

Now comes my problem. 2 of the worksheet tabs that has macro code on them
has a button on the same worksheet that the code is in and the macro code is
assigned to the button. When the save process occurs, the assignment of the
macro does not stay with the button. Instead the assignment is pointed back
to the template, instead of staying assigned to the code found on the
worksheet.
How can I make the macro assignment stay pointing to the code of the
worksheet the button is found on even if the tab is copied to a new workbook?

Thanks for any help.
--
Stephen




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Assigned Macro to button

Duh...I can be such a dunce sometimes.
:-)
Thank you for your help, that worked perfectly!
--
Stephen


"Ron de Bruin" wrote:

Double click on the button and it will open the VBA editor with the click event
Add your code
Close the editor
Click the Design mode button

Test it


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
Thank you for the prompt reply. I did your suggestion but the ActiveX Button
will not allow me to click on it to run the code. When I click on it I get
the sizing bubbles around the button. How do I get it to allow me to click on
it?
--
Stephen


"Ron de Bruin" wrote:

Hi Stephen

Use a button from the Control ToolBox(ActiveX) instead of a Forms button

This button have a click event in the sheet module and when you copy the sheet it
will copy this also to the new workbook

Private Sub CommandButton1_Click()
'enter your code here
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
I have an excel spread sheet that I use as a template. When this template
opens, I have a userform that pops up and asks the user to select one of 2
options.

Option 2 is to enable the user to perform maintenence or updates on the
template.

Option 1 saves the worksheet tabs of the template to a new book and saves
the new book as a specified file name. note: I am saving the worksheet tabs
because I do not want the modules to copy to the new file, just the tabs and
any code on the worksheet tabs.

Now comes my problem. 2 of the worksheet tabs that has macro code on them
has a button on the same worksheet that the code is in and the macro code is
assigned to the button. When the save process occurs, the assignment of the
macro does not stay with the button. Instead the assignment is pointed back
to the template, instead of staying assigned to the code found on the
worksheet.
How can I make the macro assignment stay pointing to the code of the
worksheet the button is found on even if the tab is copied to a new workbook?

Thanks for any help.
--
Stephen






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Assigned Macro to button

You are welcome

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
Duh...I can be such a dunce sometimes.
:-)
Thank you for your help, that worked perfectly!
--
Stephen


"Ron de Bruin" wrote:

Double click on the button and it will open the VBA editor with the click event
Add your code
Close the editor
Click the Design mode button

Test it


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
Thank you for the prompt reply. I did your suggestion but the ActiveX Button
will not allow me to click on it to run the code. When I click on it I get
the sizing bubbles around the button. How do I get it to allow me to click on
it?
--
Stephen


"Ron de Bruin" wrote:

Hi Stephen

Use a button from the Control ToolBox(ActiveX) instead of a Forms button

This button have a click event in the sheet module and when you copy the sheet it
will copy this also to the new workbook

Private Sub CommandButton1_Click()
'enter your code here
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Stephen sjw_ost" wrote in message
...
I have an excel spread sheet that I use as a template. When this template
opens, I have a userform that pops up and asks the user to select one of 2
options.

Option 2 is to enable the user to perform maintenence or updates on the
template.

Option 1 saves the worksheet tabs of the template to a new book and saves
the new book as a specified file name. note: I am saving the worksheet tabs
because I do not want the modules to copy to the new file, just the tabs and
any code on the worksheet tabs.

Now comes my problem. 2 of the worksheet tabs that has macro code on them
has a button on the same worksheet that the code is in and the macro code is
assigned to the button. When the save process occurs, the assignment of the
macro does not stay with the button. Instead the assignment is pointed back
to the template, instead of staying assigned to the code found on the
worksheet.
How can I make the macro assignment stay pointing to the code of the
worksheet the button is found on even if the tab is copied to a new workbook?

Thanks for any help.
--
Stephen





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 assigned to a button Sadcrab Excel Discussion (Misc queries) 12 December 8th 06 11:16 PM
Macro Assigned to a Button zephyr Excel Discussion (Misc queries) 1 October 25th 06 03:33 PM
How do I know what macro is assigned to a button? Denise in NC Excel Discussion (Misc queries) 3 April 3rd 06 02:31 PM
Which Macro Is Assigned to a Button SidBord Excel Programming 3 April 29th 04 07:57 PM
Macro assigned to a button question Anita[_2_] Excel Programming 1 July 30th 03 06:21 PM


All times are GMT +1. The time now is 04:01 PM.

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"