Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Command Button not copying with attached macro, help

I have a command button that executes a macro when clicked.
I have another macro that makes a copy of my template sheet.
If I manually make a copy of the template sheet, the button copies along
with the attached macro. If I used the macro to make a copy, the button is
copied with the text "Button 2" and does not bring the attached macro with it.
When I recorded the macro for copying the sheet, I used the same steps that
I use when doing it manually.
What am I doing wrong?

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Command Button not copying with attached macro, help

Are you copying the entire sheet (like edit|move or copy sheet) or are you
selecting a range and then copy|pasting that range?

It may be easiest to copy the entire sheet. Then the commandbutton and all the
code behind the worksheet will travel with the copy.

BABs wrote:

I have a command button that executes a macro when clicked.
I have another macro that makes a copy of my template sheet.
If I manually make a copy of the template sheet, the button copies along
with the attached macro. If I used the macro to make a copy, the button is
copied with the text "Button 2" and does not bring the attached macro with it.
When I recorded the macro for copying the sheet, I used the same steps that
I use when doing it manually.
What am I doing wrong?

TIA


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Command Button not copying with attached macro, help

Dave,
Thx for the reply.
If I right click on the sheet tab and do "move or copy" then "create copy"
for the sheet, it copies the macro with the button. Life is good.
I wanted to automate this process because I repeat it often.
I clicked "record a macro", then followed the same steps, right click on the
tab, "move or copy", create a copy, then stopped recording.
I set the macro for Ctrl+shift+c.
If I hit ctrl+shift+c, it creates a copy of the sheet (calls it sheet (2)),
but the button does not have the macro attached to it and now shows the text
"button 2", instead of the "Balance yield" on the original button.
Same procedure as I see it, just different products.
Any ideas?






"Dave Peterson" wrote:

Are you copying the entire sheet (like edit|move or copy sheet) or are you
selecting a range and then copy|pasting that range?

It may be easiest to copy the entire sheet. Then the commandbutton and all the
code behind the worksheet will travel with the copy.

BABs wrote:

I have a command button that executes a macro when clicked.
I have another macro that makes a copy of my template sheet.
If I manually make a copy of the template sheet, the button copies along
with the attached macro. If I used the macro to make a copy, the button is
copied with the text "Button 2" and does not bring the attached macro with it.
When I recorded the macro for copying the sheet, I used the same steps that
I use when doing it manually.
What am I doing wrong?

TIA


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Command Button not copying with attached macro, help

Are you sure you used a commandbutton from the control toolbox toolbar?

It sounds like you used a button from the Forms toolbar. Those buttons have
macros (in a general module) assigned to them.

If you use that commandbutton from the control toolbox toolbar, you'll find that
life gets much simpler. You will have to move the code into the
Commandbutton1_click event (in the worksheet module), though.

BABs wrote:

Dave,
Thx for the reply.
If I right click on the sheet tab and do "move or copy" then "create copy"
for the sheet, it copies the macro with the button. Life is good.
I wanted to automate this process because I repeat it often.
I clicked "record a macro", then followed the same steps, right click on the
tab, "move or copy", create a copy, then stopped recording.
I set the macro for Ctrl+shift+c.
If I hit ctrl+shift+c, it creates a copy of the sheet (calls it sheet (2)),
but the button does not have the macro attached to it and now shows the text
"button 2", instead of the "Balance yield" on the original button.
Same procedure as I see it, just different products.
Any ideas?

"Dave Peterson" wrote:

Are you copying the entire sheet (like edit|move or copy sheet) or are you
selecting a range and then copy|pasting that range?

It may be easiest to copy the entire sheet. Then the commandbutton and all the
code behind the worksheet will travel with the copy.

BABs wrote:

I have a command button that executes a macro when clicked.
I have another macro that makes a copy of my template sheet.
If I manually make a copy of the template sheet, the button copies along
with the attached macro. If I used the macro to make a copy, the button is
copied with the text "Button 2" and does not bring the attached macro with it.
When I recorded the macro for copying the sheet, I used the same steps that
I use when doing it manually.
What am I doing wrong?

TIA


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Command Button not copying with attached macro, help

If your template is file type .xlt, why not just use SaveAs to make a copy?
It would take everything with it.

"BABs" wrote:

I have a command button that executes a macro when clicked.
I have another macro that makes a copy of my template sheet.
If I manually make a copy of the template sheet, the button copies along
with the attached macro. If I used the macro to make a copy, the button is
copied with the text "Button 2" and does not bring the attached macro with it.
When I recorded the macro for copying the sheet, I used the same steps that
I use when doing it manually.
What am I doing wrong?

TIA



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Command Button not copying with attached macro, help

The template is just the name of a worksheet in my workbook. I leave that
sheet with only my formulas on it. I make a copy of it and then enter
numbers into the formulas for calculation on the copy.
It seems like the easiest way for me????????






"JLGWhiz" wrote:

If your template is file type .xlt, why not just use SaveAs to make a copy?
It would take everything with it.

"BABs" wrote:

I have a command button that executes a macro when clicked.
I have another macro that makes a copy of my template sheet.
If I manually make a copy of the template sheet, the button copies along
with the attached macro. If I used the macro to make a copy, the button is
copied with the text "Button 2" and does not bring the attached macro with it.
When I recorded the macro for copying the sheet, I used the same steps that
I use when doing it manually.
What am I doing wrong?

TIA

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 attached to command button - VBA form Roy Gudgeon[_2_] Excel Discussion (Misc queries) 2 March 16th 10 12:44 PM
Macro attached to Menu Command Button Steven Excel Programming 2 July 3rd 08 02:47 PM
Macro attached to button runs twice Jozef[_2_] Excel Programming 0 November 4th 04 01:36 PM
MACRO ATTACHED TO A TOOLBAR BUTTON Joyce[_2_] Excel Programming 0 October 9th 03 07:30 PM
Excel open an existing MS Query in edit mode via macro attached to a button. systems analyst Excel Programming 1 October 3rd 03 12:08 PM


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