ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Button & Code question (https://www.excelbanter.com/excel-programming/328301-copy-button-code-question.html)

Stuart[_21_]

Copy Button & Code question
 
I have a workbook with a Master and Summary sheet.
It will become a Template, (or perhaps read only xls).
Buttons on the Master allow the user to do simple things like add a sheet,
reorder sheets, etc.

When they add a sheet via the button on the Master, I'd like to copy a
hidden button from the Master, and place it on the new sheet (including the
code).

Can I do this, and if so, how, please?

Regards.



Tom Ogilvy

Copy Button & Code question
 
Easier to have the generalized code in a general module and use a button
from the forms toolbar. then you just add it (macro recorder) and assign
it to the macro. (OnAction property).

In the generalized code

Sub General_Button_Click()
sName = Application.Caller
btn = Activesheet.Buttons(sName)
msgbox btn.Caption
End Sub

Or
http://www.cpearson.com/excel/vbe.htm

and the macro recorder shows how to copy or add a commandbutton. (why
copy - just add it and format it as you wish with code).


--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I have a workbook with a Master and Summary sheet.
It will become a Template, (or perhaps read only xls).
Buttons on the Master allow the user to do simple things like add a sheet,
reorder sheets, etc.

When they add a sheet via the button on the Master, I'd like to copy a
hidden button from the Master, and place it on the new sheet (including

the
code).

Can I do this, and if so, how, please?

Regards.





Stuart[_21_]

Copy Button & Code question
 
Thanks for the code and guidance.

Regards.

"Tom Ogilvy" wrote in message
...
Easier to have the generalized code in a general module and use a button
from the forms toolbar. then you just add it (macro recorder) and assign
it to the macro. (OnAction property).

In the generalized code

Sub General_Button_Click()
sName = Application.Caller
btn = Activesheet.Buttons(sName)
msgbox btn.Caption
End Sub

Or
http://www.cpearson.com/excel/vbe.htm

and the macro recorder shows how to copy or add a commandbutton. (why
copy - just add it and format it as you wish with code).


--
Regards,
Tom Ogilvy

"Stuart" wrote in message
...
I have a workbook with a Master and Summary sheet.
It will become a Template, (or perhaps read only xls).
Buttons on the Master allow the user to do simple things like add a
sheet,
reorder sheets, etc.

When they add a sheet via the button on the Master, I'd like to copy a
hidden button from the Master, and place it on the new sheet (including

the
code).

Can I do this, and if so, how, please?

Regards.








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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com