Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
workbook code - new sheet created... | Excel Programming | |||
Macro Created but Not Running in Workbook | Excel Worksheet Functions | |||
Trying To Push Code For Worksheet_Change Into VBA-Created Workbook? | Excel Programming | |||
How do I copy macro into new workbook that was created automatica. | Excel Programming | |||
Adding Code to the This_workbook module of a created workbook | Excel Programming |