Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default 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
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
Macros inside Excel Mark Excel Worksheet Functions 4 October 10th 06 03:17 AM
How to refer to a cell format code? A difficult problem Excel Discussion (Misc queries) 1 May 25th 05 08:42 AM
Refer to Worksheet Ranges in Code Andibevan[_2_] Excel Programming 8 March 30th 05 12:20 PM
Macros inside macros, and pasting into macro code. pagelocator[_2_] Excel Programming 1 November 24th 04 09:11 AM
refer to the sheets Name property in my code (not what is on the Tab) Sandy[_5_] Excel Programming 3 January 29th 04 08:45 PM


All times are GMT +1. The time now is 08:03 PM.

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"