ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying VBA Code from one Sheet to another (https://www.excelbanter.com/excel-programming/390570-copying-vba-code-one-sheet-another.html)

Josh

Copying VBA Code from one Sheet to another
 
Hello!
I have a template that creates 5 sheets. I would like the code from
sheet 1 and sheet 1's properties to be copied over to the 5 created sheets.
They are created with VBA. Is this possible? I have posted elsewhere with no
response. For example, I have buttons on the first sheet that do certain
things with the code for those buttons being within that sheet. When the 5
other sheets are created I can get the sheets to duplicate as far as
appearance but I cannot get the buttons to retain the functionality of the
first sheet.

Thanks!
Josh

Don Guillett

Copying VBA Code from one Sheet to another
 
As ALWAYS, post YOUR code for comments.

--
Don Guillett
SalesAid Software

"Josh" wrote in message
...
Hello!
I have a template that creates 5 sheets. I would like the code from
sheet 1 and sheet 1's properties to be copied over to the 5 created
sheets.
They are created with VBA. Is this possible? I have posted elsewhere with
no
response. For example, I have buttons on the first sheet that do certain
things with the code for those buttons being within that sheet. When the 5
other sheets are created I can get the sheets to duplicate as far as
appearance but I cannot get the buttons to retain the functionality of the
first sheet.

Thanks!
Josh



joel

Copying VBA Code from one Sheet to another
 
If you are using Command Button Click macros they only work on one worksheet.
You have to go to the VBA editor and copy the code from sheet1 to the other
sheets before they will work.

"Josh" wrote:

Hello!
I have a template that creates 5 sheets. I would like the code from
sheet 1 and sheet 1's properties to be copied over to the 5 created sheets.
They are created with VBA. Is this possible? I have posted elsewhere with no
response. For example, I have buttons on the first sheet that do certain
things with the code for those buttons being within that sheet. When the 5
other sheets are created I can get the sheets to duplicate as far as
appearance but I cannot get the buttons to retain the functionality of the
first sheet.

Thanks!
Josh


Josh

Copying VBA Code from one Sheet to another
 
You don't need to see the code in this case...it is only a question regarding
a process.

"Don Guillett" wrote:

As ALWAYS, post YOUR code for comments.

--
Don Guillett
SalesAid Software

"Josh" wrote in message
...
Hello!
I have a template that creates 5 sheets. I would like the code from
sheet 1 and sheet 1's properties to be copied over to the 5 created
sheets.
They are created with VBA. Is this possible? I have posted elsewhere with
no
response. For example, I have buttons on the first sheet that do certain
things with the code for those buttons being within that sheet. When the 5
other sheets are created I can get the sheets to duplicate as far as
appearance but I cannot get the buttons to retain the functionality of the
first sheet.

Thanks!
Josh




Norman Jones

Copying VBA Code from one Sheet to another
 
Hi Josh,

'----------------
You don't need to see the code in this case...it is only a question
regarding
a process.

'----------------

If the copied sheets' code does not perform as expected,
then I think that it would need to post your code, as
indicated by Don.

In the interim, comsider replacing any hard-coded sheet
references in the original CommandButton code - possibly
replacing such references with the keyword Me. If,
alternatively, the buttons are from the Forms toolbar, perhaps
consider using the application's Caller property to return the
requisite sheet.


---
Regards,
Norman



Don Guillett

Copying VBA Code from one Sheet to another
 
Good luck

--
Don Guillett
SalesAid Software

"Josh" wrote in message
...
You don't need to see the code in this case...it is only a question
regarding
a process.

"Don Guillett" wrote:

As ALWAYS, post YOUR code for comments.

--
Don Guillett
SalesAid Software

"Josh" wrote in message
...
Hello!
I have a template that creates 5 sheets. I would like the code from
sheet 1 and sheet 1's properties to be copied over to the 5 created
sheets.
They are created with VBA. Is this possible? I have posted elsewhere
with
no
response. For example, I have buttons on the first sheet that do
certain
things with the code for those buttons being within that sheet. When
the 5
other sheets are created I can get the sheets to duplicate as far as
appearance but I cannot get the buttons to retain the functionality of
the
first sheet.

Thanks!
Josh





JLatham

Copying VBA Code from one Sheet to another
 
I agree with Don Guillet (and others) that seeing your code would be a big
help. Remember, for folks to help you here on their dime, you need to be
reasonably responsive to their requests for more information.

Personall, sounds to me like you need to create one sheet with the code as
part of it, or with the buttons pre-assigned to macros in a regular module,
and then copy that sheet to create your 5 sheets and modify them however it
is you want them to be within your code. Copying a sheet does copy all
objects and the code associated with that sheet.

If you are placing the buttons on the sheets using VBA code, one part of
that process is going to have to be the equivalent of "Assign Macro".

"Josh" wrote:

Hello!
I have a template that creates 5 sheets. I would like the code from
sheet 1 and sheet 1's properties to be copied over to the 5 created sheets.
They are created with VBA. Is this possible? I have posted elsewhere with no
response. For example, I have buttons on the first sheet that do certain
things with the code for those buttons being within that sheet. When the 5
other sheets are created I can get the sheets to duplicate as far as
appearance but I cannot get the buttons to retain the functionality of the
first sheet.

Thanks!
Josh


Dave Peterson

Copying VBA Code from one Sheet to another
 
If you copy that sheet (not just the cells), then the code behind the worksheet
will be under the new sheet, too.

In code, it would be the equivalent of Edit|Move or copy sheet.

Josh wrote:

Hello!
I have a template that creates 5 sheets. I would like the code from
sheet 1 and sheet 1's properties to be copied over to the 5 created sheets.
They are created with VBA. Is this possible? I have posted elsewhere with no
response. For example, I have buttons on the first sheet that do certain
things with the code for those buttons being within that sheet. When the 5
other sheets are created I can get the sheets to duplicate as far as
appearance but I cannot get the buttons to retain the functionality of the
first sheet.

Thanks!
Josh


--

Dave Peterson


All times are GMT +1. The time now is 10:34 AM.

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