Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Copy VBA code into a workbook created by a macro

Excel 2003.

I have some code which takes a number of worksheets from the open workbook
and copies them to a new workbook. It then manipulates the data and saves the
new workbook without altering the original.

I need to bring a macro from the original workbook across so that when the
new file is opened independantly the macro can be run.

Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Copy VBA code into a workbook created by a macro

Hi,

The problem with that approach is that you then have 2 versions of the same
macro or maybe even more if you repeat the operation any of which can get out
of synch if you modify the macro.

Why don't you put this macro in personal.xls then you have a single copy
available to all workbooks.

Mike

"Planner Rob" wrote:

Excel 2003.

I have some code which takes a number of worksheets from the open workbook
and copies them to a new workbook. It then manipulates the data and saves the
new workbook without altering the original.

I need to bring a macro from the original workbook across so that when the
new file is opened independantly the macro can be run.

Any suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy VBA code into a workbook created by a macro

I like Mike H's idea of separating the code from the workbooks that need the
macros. But I wouldn't use personal.xls.

I'd create a separate dedicated workbook for those macros--and only open it when
I needed it.

And if I needed to share the macros with another user, I could just share that
dedicated workbook. I wouldn't have to worry about any existing personal.xls
workbook that the other user has.

Planner Rob wrote:

Excel 2003.

I have some code which takes a number of worksheets from the open workbook
and copies them to a new workbook. It then manipulates the data and saves the
new workbook without altering the original.

I need to bring a macro from the original workbook across so that when the
new file is opened independantly the macro can be run.

Any suggestions?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Copy VBA code into a workbook created by a macro

Why not use a template with the code already in it?

Create a new workbook from that and then copy your data into it.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy VBA code into a workbook created by a macro

I find the problem with that is that every new workbook that I create using that
template has the code in it. And if the code has to change, I'll never be able
to find all the copies of all the workbooks that have that code.

With the separate workbook for just the code, I have a better chance.

norie wrote:

Why not use a template with the code already in it?

Create a new workbook from that and then copy your data into it.


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Copy VBA code into a workbook created by a macro

Dave

I can kind of understand that but without knowing what the OP's code
is it's hard to tell if it matters.

Is the code going to be changed in the future?

If so is it possible that the code could be rewritten in some way to
take into account changes?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy VBA code into a workbook created by a macro

If you've ever had co-workers or a boss, you'll realize that the code will
always change <vbg. There's always one more thing to fix or add to make it
perfect.

And if the code is spread over 100's of workbooks (or more), I'm not sure how
anyone would know to find them to change them--even if the code could be
rewritten mechanically.

norie wrote:

Dave

I can kind of understand that but without knowing what the OP's code
is it's hard to tell if it matters.

Is the code going to be changed in the future?

If so is it possible that the code could be rewritten in some way to
take into account changes?


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default Copy VBA code into a workbook created by a macro

Dave

I suppose I've been lucky, most of the positions I had where working
with one or two people on specific projects.

And if the job got done properly everybody was happy - though that
didn't mean things didn't change,

In fact sometimes on certain projects the targets and hence the code/
whatever changed on a daily basis.

As for writing code mechanically - that's not really what I meant.

I meant write code that will cope with the changes.

Whether that's an option for this OP is impossible to tell without
seeing the code or at least more information on what it's purpose is.

Oh, and you can write code that will write/delete/alter code but doing
so can bring up other issues.

One of those issues is security, which I imagine could be a major
issue when dealing with multiple users.

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
workbook code - new sheet created... J.W. Aldridge Excel Programming 5 May 1st 09 09:24 PM
Macro Created but Not Running in Workbook alexaed Excel Worksheet Functions 9 August 14th 07 08:48 PM
Trying To Push Code For Worksheet_Change Into VBA-Created Workbook? (PeteCresswell) Excel Programming 1 July 6th 07 01:39 PM
How do I copy macro into new workbook that was created automatica. Darshan Excel Programming 3 January 11th 05 01:24 AM
Adding Code to the This_workbook module of a created workbook RPIJG[_68_] Excel Programming 1 July 9th 04 06:35 PM


All times are GMT +1. The time now is 02:41 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"