Copy and pasting VBA modules in workbook

Microsoft Microsoft excel 2000 95/98/me/...
July 6, 2010 at 06:53:34
Specs: Windows XP
I am trying to copy all of my code from module 5 and replace all values containing "PRGNAME" with txtNewProgram.Value which is defined for my user form. I then want to paste all of this code into Module 3 at the end, such as not to overwrite the code already there. I would like the code to be able to add to the end of module 3 every time.

Any help is appreciated!


See More: Copy and pasting VBA modules in workbook

Report •

#1
July 6, 2010 at 07:22:02
re: I am trying to copy all of my code from module 5 and replace all values containing "PRGNAME" with txtNewProgram.Value

Do you mean that you want to change the macro itself to read txtNewProgram.Value everywhere that it says PRGNAME?

If so, you can use Edit Replace...Replace All in the VBA editor, just like you can in an Excel worksheet.

If you don't want to Replace All, the Find Next...Replace option is also available so that you can pick and choose which values to Replace.

If you want to limit the changes to a specific section of code, highlight that section of code and then do an Edit...Replace.

re: I then want to paste all of this code into Module 3 at the end, such as not to overwrite the code already there.

Highlight the code in Module 5, Right Click...Copy, double click Module 3, scroll to the bottom and Rightclick...Paste. As long as there are no other pieces of code with the same name in that module, you should have no problem.

re: I would like the code to be able to add to the end of module 3 every time.

Every time? Every time when? You'll need to explain that one in a little more detail.


Report •

#2
July 6, 2010 at 08:07:38
I know that I can do this all manually, however I would like it to do all of those things that you described above to complete automatically upon submission of my userform.

And what I mean by every time, is that this userform will be completed more than once, and I need the code to build on itself in module 3.


Report •
Related Solutions


Ask Question