Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default 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

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Slow code when used as VBA code instead of macro (copying visible columns) [email protected] Excel Programming 3 April 2nd 07 05:26 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
Copying cells from on sheet to another sheet (via sheet module) CRayF Excel Programming 6 September 20th 05 08:58 PM
Sheet Code Module: copying code to [email protected][_2_] Excel Programming 2 December 14th 04 01:57 AM
VBA code for selecting and copying rows to another sheet. lothario[_6_] Excel Programming 4 October 14th 03 01:15 PM


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