Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Report with macro losing links to a particular worksheet after running macro | Excel Programming | |||
disable user running macro from Tools Macro | Excel Discussion (Misc queries) | |||
Need syntax for RUNning a Word macro with an argument, called from an Excel macro | Excel Programming | |||
how to get onkey macro to fire while another macro is running | Excel Programming | |||
Launch Macro in Access via Macro running in Excel??? | Excel Programming |