Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

call or run a macro using concantenation 1

Status
Not open for further replies.

Pedrovo

Technical User
Nov 1, 2022
1
FR
This should be very simple... if you know what you're doing.
I just need to run a macro using the root of the name... Im_Dot_ and then add the number of the dot to the end of the name.
For example: I need to call the macro named Im_Dot_13.
The number 13 is derived by a loop of variables from 12 to 23. I designated this number as DotNum.
I've tried Application.Run ("Im_Dot_" & DotNum), but this doesn't work.
Either using Application.Run or Call... how would I run this macro? Thanks.
 
I would create a VB Script that takes DotNum as parameter, creates the proper name and launches that macro.
Once that works, all you would need would be to point your existing action to the VB Script and send the proper DotNum.

I've got nothing to hide, and I demand that you justify what right you have to ask.
 
So, what you are saying you have macros:

Code:
Option Explicit

Sub Im_Dot_12
...
End Sub

Sub Im_Dot_13
...
End Sub[red]
... etc.[/red]
Sub Im_Dot_23
...
End Sub

Are these different macros with different code?
Or the code is the same and the only difference is your DotNum?

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
The best approach is almost certainly something else.

Why don't you explain what you need to do instead of how you think it should be done.
 
>Application.Run ("Im_Dot_" & DotNum), but this doesn't work

In what sense?
 
At any rate, this works for me.

Code:
Public Sub Run_Me()
    MsgBox ("Run_Me ran!")
End Sub


Public Sub Run_You()
    MsgBox ("Run_You ran!")
End Sub



Public Sub Starter(who As String)

Dim target As String

 target = "Run_" & who
 
    Application.Run (target)

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top