Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro Running Another Macro

Is it possible to create a macro that just runs a few other macros? I have 12
separate macros with separate shortcuts and it'd be easier to have one
shortcut. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Macro Running Another Macro

sub Mark()

call MarkFormatting
call MarkCopying
call MarkPrinting

End Sub

you can call as many as you want from the main macro, and they can be
contained in other modules.
hope that helps!
:)
susan


On Jan 22, 2:35*pm, Mark P wrote:
Is it possible to create a macro that just runs a few other macros? I have 12
separate macros with separate shortcuts and it'd be easier to have one
shortcut. Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Macro Running Another Macro

Actually, you don't even have to use the "Call" keyword as it's assumed in
VBA.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Susan" wrote in message
...
sub Mark()

call MarkFormatting
call MarkCopying
call MarkPrinting

End Sub

you can call as many as you want from the main macro, and they can be
contained in other modules.
hope that helps!
:)
susan


On Jan 22, 2:35 pm, Mark P wrote:
Is it possible to create a macro that just runs a few other macros? I have
12
separate macros with separate shortcuts and it'd be easier to have one
shortcut. Thanks!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Macro Running Another Macro

Ronald - personal choice, i guess - i hate not using "call" because
then in the code you've got this "MarkFormatting" text hanging out
there all alone with no indication of what it is or what it's doing.
yes i may remember today what it is, but six months from now? by
using the "call" keyword i'm reminding myself of what "MarkFormatting"
is and what it's doing.
like i said, personal choice, but technically you're right. :)
susan


On Jan 22, 2:44*pm, "Ronald R. Dodge, Jr."
wrote:
Actually, you don't even have to use the "Call" keyword as it's assumed in
VBA.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000"Susan" wrote in message

...
sub Mark()

call MarkFormatting
call MarkCopying
call MarkPrinting

End Sub

you can call as many as you want from the main macro, and they can be
contained in other modules.
hope that helps!
:)
susan

On Jan 22, 2:35 pm, Mark P wrote:



Is it possible to create a macro that just runs a few other macros? I have
12
separate macros with separate shortcuts and it'd be easier to have one
shortcut. Thanks!- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Macro Running Another Macro

Even though I do remember the old BASIC days, within VBA, every line starts
with a keyword except for maybe called on procedures or letting simple data
types equal to some value (Yes, this includes properties and arrays that use
simple data types). For those statement lines that's not starting with key
words (at least within my VBA, marked as cyan color), then it's obviously a
call to something or an expression setting/letting (Set keyword must be used
for objects, but Let keyword is understood for simple data types) to some
object/value respectively.

For you, I guess you use the Call keyword to distinguish what methods are
being called on. Do you also use the Let keyword to distinguish which lines
are letting simple data types equal to some value?

Now as far as how I do it, since I like to keep my stuff as short as
reasonably possible, but still want readability for debugging and
modification purposes, I use method and variable naming schemes, so as I
know what is what. The following as just a sample list.

l_str (This indicates to me that this is a string variable within the
procedure)

l, m, and g for that first letter with variable names.
Different 3 letter codes for different variable types.
prp for properties
pcd for methods setup as a procedure
fnc for methods setup as a function
ro on properties with only Get statement
wo on properties with only Let/Set statement
rw on properties with both Get and Let/Set statements.

prp_<type of property code_<PropertyName like:

prp_rw_Value for a property with the Value name that is both read and write.

so in my case, if I was to setup the call, it would be like

pcdMarkFormatting '(If this is a call to a Sub)

OR

fncMarkFormatting '(If this is a call to a Function)


Of course, I realize many of us have different things, but the same basic
idea to achieve the same basic deal.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Susan" wrote in message
...
Ronald - personal choice, i guess - i hate not using "call" because
then in the code you've got this "MarkFormatting" text hanging out
there all alone with no indication of what it is or what it's doing.
yes i may remember today what it is, but six months from now? by
using the "call" keyword i'm reminding myself of what "MarkFormatting"
is and what it's doing.
like i said, personal choice, but technically you're right. :)
susan


On Jan 22, 2:44 pm, "Ronald R. Dodge, Jr."
wrote:
Actually, you don't even have to use the "Call" keyword as it's assumed in
VBA.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000"Susan" wrote in message

...
sub Mark()

call MarkFormatting
call MarkCopying
call MarkPrinting

End Sub

you can call as many as you want from the main macro, and they can be
contained in other modules.
hope that helps!
:)
susan

On Jan 22, 2:35 pm, Mark P wrote:



Is it possible to create a macro that just runs a few other macros? I
have
12
separate macros with separate shortcuts and it'd be easier to have one
shortcut. Thanks!- Hide quoted text -


- Show quoted text -





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Macro Running Another Macro

I'm with Susan on this, code is unreadable without Call.
And it gets a lot worse when passing variables to code:

DoSomethingUseful X, MyString, MyCell, strWarningText

vs

Call DoSomethingUseful (X, MyString, MyCell, strWarningText)

Best wishes Harald

"Ronald R. Dodge, Jr." skrev i melding
...
Actually, you don't even have to use the "Call" keyword as it's assumed in
VBA.



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Macro Running Another Macro

What sort of issues have you had without using the Call keyword? I been
doing it without the Call keyword from the start of me using VBA back in
1998 and never once have I had a problem without using the Call keyword.

The only thing I see based on how you using the 2 lines below, the first
line is calling up the command as if it's being used as a "Sub" call (Rather
if the method is a Sub or Function) vs. the second one is being used as a
"Function" call (The method is a Function). How can I tell? First call
(implied), you don't use the parenthesizes and the second call, you do.

Sub calls, you can only use without the parenthesizes vs. Function calls,
you can use the parenthesizes, but don't have to. However, that depends if
you are using the method as a function to return something (Use the
parenthesizes) or if you are using it as a sub just to execute something
(Don't use the parenthesizes).

However, if you do use the parenthesizes, you must have it either equal to
something (via either Let [in many cases, you see this left off too, but can
be used] or Set) or have it in an argument that will take the value/object
of what the function returns.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Harald Staff" wrote in message
...
I'm with Susan on this, code is unreadable without Call.
And it gets a lot worse when passing variables to code:

DoSomethingUseful X, MyString, MyCell, strWarningText

vs

Call DoSomethingUseful (X, MyString, MyCell, strWarningText)

Best wishes Harald

"Ronald R. Dodge, Jr." skrev i melding
...
Actually, you don't even have to use the "Call" keyword as it's assumed
in VBA.





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Macro Running Another Macro

Hi Ronald

As stated, this is only about making the code readable and self explaining.
I hate writing code documentation.
You are not right about sub and function calls. Try this:

Sub test()
Dim S As String

' sub calls:
MessageMe "First message", 1
Call MessageMe("Second message", 2)

'function calls:
MsgBox SheSaid("Watch this")
S = SheSaid("And this")
MsgBox S
Call SheSaid("You won't see this")
MsgBox SheSaid "This errs"
S = SheSaid "This too"
MsgBox S
End Sub

Sub MessageMe(strMsg As String, LCounter As Long)
MsgBox strMsg & vbNewLine & vbNewLine & _
"This is example number " & LCounter
End Sub

Function SheSaid(strMsg As String) As String
SheSaid = "The lady said: " & strMsg
End Function

A sub is just a function returning nothing (Void), so from a code point of
view the difference is very little.

Best wishes Harald

"Ronald R. Dodge, Jr." wrote in message
...
What sort of issues have you had without using the Call keyword? I been
doing it without the Call keyword from the start of me using VBA back in
1998 and never once have I had a problem without using the Call keyword.

The only thing I see based on how you using the 2 lines below, the first
line is calling up the command as if it's being used as a "Sub" call
(Rather if the method is a Sub or Function) vs. the second one is being
used as a "Function" call (The method is a Function). How can I tell?
First call (implied), you don't use the parenthesizes and the second call,
you do.

Sub calls, you can only use without the parenthesizes vs. Function calls,
you can use the parenthesizes, but don't have to. However, that depends
if you are using the method as a function to return something (Use the
parenthesizes) or if you are using it as a sub just to execute something
(Don't use the parenthesizes).

However, if you do use the parenthesizes, you must have it either equal to
something (via either Let [in many cases, you see this left off too, but
can be used] or Set) or have it in an argument that will take the
value/object of what the function returns.

--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Harald Staff" wrote in message
...
I'm with Susan on this, code is unreadable without Call.
And it gets a lot worse when passing variables to code:

DoSomethingUseful X, MyString, MyCell, strWarningText

vs

Call DoSomethingUseful (X, MyString, MyCell, strWarningText)

Best wishes Harald

"Ronald R. Dodge, Jr." skrev i melding
...
Actually, you don't even have to use the "Call" keyword as it's assumed
in VBA.






  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro Running Another Macro

Hi,

Put all your macro names in a seperate sub and call them sequentially

Sub RunEmAll()
Mymacro1
Mymacro2
Mymacro3
Mymacro4
'etc
End Sub

Mike


On Thu, 22 Jan 2009 11:35:01 -0800, Mark P
wrote:

Is it possible to create a macro that just runs a few other macros? I have 12
separate macros with separate shortcuts and it'd be easier to have one
shortcut. Thanks!

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Macro Running Another Macro

Sub Demo()
Call Hello
End Sub

Sub Hello()
Msgbox("Hello")
End Sub
--
Gary''s Student - gsnu200828


"Mark P" wrote:

Is it possible to create a macro that just runs a few other macros? I have 12
separate macros with separate shortcuts and it'd be easier to have one
shortcut. Thanks!



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
Report with macro losing links to a particular worksheet after running macro santhu Excel Programming 0 March 1st 07 03:25 AM
disable user running macro from Tools Macro Steve Simons Excel Discussion (Misc queries) 4 September 28th 06 06:28 AM
Need syntax for RUNning a Word macro with an argument, called from an Excel macro Steve[_84_] Excel Programming 3 July 6th 06 07:42 PM
how to get onkey macro to fire while another macro is running Brian Murphy Excel Programming 8 August 25th 04 05:38 AM
Launch Macro in Access via Macro running in Excel??? dgrant Excel Programming 1 September 24th 03 01:38 PM


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

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

About Us

"It's about Microsoft Excel"