Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I refer to other macros inside a macro code?
Is it possible to run other macros from inside a macro code? I ask this
because I would like to keep the code entities as simple as possible and therefore not to make them too long by adding all the code in one macro and then typing the same code in other places where it is needed. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I refer to other macros inside a macro code?
use "call <macro name"
it should work hth MPG "Erkka" wrote in message ... Is it possible to run other macros from inside a macro code? I ask this because I would like to keep the code entities as simple as possible and therefore not to make them too long by adding all the code in one macro and then typing the same code in other places where it is needed. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I refer to other macros inside a macro code?
Sub Macro1()
'do some stuff Call Macro2 'do seom more End SUb Sub Macro2() 'do some macro2 stuff Enbd Sub -- HTH Bob Phillips "Erkka" wrote in message ... Is it possible to run other macros from inside a macro code? I ask this because I would like to keep the code entities as simple as possible and therefore not to make them too long by adding all the code in one macro and then typing the same code in other places where it is needed. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do I refer to other macros inside a macro code?
Erkka wrote: Is it possible to run other macros from inside a macro code? I ask this because I would like to keep the code entities as simple as possible and therefore not to make them too long by adding all the code in one macro and then typing the same code in other places where it is needed. This is "a", if not "the", way to do it. In Walkenbach he talks about writing shorter macros, then stitching them together. It works for me. It keeps the amount of code I'm working on at any one time small and easier to debug. And it "modularizes" the code. Once I have code that say, finds a value and then does something to modify the column that value is in, I can reuse it in other programs where I need something similiar. It's also useful for some kinds of programs that I use stand-alone and in other code. I.e., I work with a lot of data downloaded data from a program called SPSS, a statistics program. The downloaded files are "dirty" to XL. Lot's of invisible "stuff" in both empty cells and cells with data in them that can cause problems working in XL. I found a program online that removes the "dirt" from these files. In some cases, I just run my macro "Clean" to remove the nasty stuff. I also have a program that reformats certain kinds of these downloaded files to be used in another spreadsheet. I have a macro that runs the "Clean" macro first, then reformats the sheet. So "Clean" can be a standalone macro when I need it, and called by another macro when it's just part of a larger process. I think it's definitely a good idea to modularize this way. Keep in mind, I'm still new to VBA programming, so maybe there are disadvantages I haven't seen yet. Some of the more experienced people here can probably help us both with that aspect of this issue. Hope this helps in your world. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macros inside Excel | Excel Worksheet Functions | |||
How to refer to a cell format code? | Excel Discussion (Misc queries) | |||
Refer to Worksheet Ranges in Code | Excel Programming | |||
Macros inside macros, and pasting into macro code. | Excel Programming | |||
refer to the sheets Name property in my code (not what is on the Tab) | Excel Programming |