×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

call or run a macro using concantenation

call or run a macro using concantenation

call or run a macro using concantenation

(OP)
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.

RE: call or run a macro using concantenation

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.

RE: call or run a macro using concantenation

So, what you are saying you have macros:

CODE

Option Explicit

Sub Im_Dot_12
...
End Sub

Sub Im_Dot_13
...
End Sub
... etc.
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

RE: call or run a macro using concantenation

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.

RE: call or run a macro using concantenation

>Application.Run ("Im_Dot_" & DotNum), but this doesn't work

In what sense?

RE: call or run a macro using concantenation

At any rate, this works for me.

CODE --> VBA

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 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close