Hi,
To my understanding there is no way to call a sub from a name
variable. Rather than passing a parameter to a sub with different
'sections' though, wouldn't it be easier to move the 'if' back into
the first sub?
sub Macro1()
Dim NextSub
do some things
NextSub = whatever you choose
Select Case NextSub
Case "Macro2"
Call Macro2
Case "Macro3"
Call Macro3
etc. etc.
End Select
End Sub
Hard to say withouu seeing you code.
Cheers,
Ivan.
On Apr 2, 10:21*pm, paul.robin...@it-tallaght.ie wrote:
> Hi
> didn't test this before. Looks like you simply cannot call a variable
> name macro.
> I'd suggest you create one macro with a variable parameter
>
> Sub myMacro (i as integer)
> * * 'code depending on i
> end sub
>
> Then in the loop do
> Call myMacro i
>
> regards
> Paul
> On Apr 2, 10:16*am, Whit <W...@discussions.microsoft.com> wrote:
>
>
>
> > I get a compile error...
>
> > "paul.robin...@it-tallaght.ie" wrote:
> > > Hi
> > > You don't use brackets.
> > > * * * * Call MacroName
>
> > > or if it has parameters
>
> > > * * * * Call MacroName variable1, variable2, etc
>
> > > regards
> > > Paul
>
> > > On Apr 2, 10:01 am, Whit <W...@discussions.microsoft.com> wrote:
> > > > How can I call a macro when the name is a variable
>
> > > > * * MacroName = "example"
> > > > * * While i <= 14
> > > > * * * * MacroName = MacroName & i
> > > > * * * * Call MacroName (path)
> > > > * * * * i = i + 1
> > > > * * Loop
>
> > > > Cheers- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
|