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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Sub using Variable PPT VBA 2000

Status
Not open for further replies.

tgmoon

Technical User
Jan 31, 2001
54
GB
Hi.

I'm getting a little confused. Should I be able to run a Sub using a variable.

i.e.

Sub SomeThing()
Call SomethingElse("etc", "MYSUB")
End Sub


Function SomethingElse(str1 As String, str2 As String)
some code = str1
str2
End Function

Hope that sort of makes sense but the str2 is where i want another sub called

At the moment i get a Complie error: Expected Sub, Function, or Property.
 
As in:
Code:
Option Explicit

Sub SomeThing()
  Call SomethingElse("etc", "MYSUB")
End Sub


Function SomethingElse(str1 As String, str2 As String)
  Dim someCode As String
  someCode = str1
  Application.Run str2
End Function

Sub MYSUB()
MsgBox "hello world"
End Sub

Gerry
 
Thanks everyone.

Working a treat now, though i'm now trying to work out how to make the str2 optional!!
 
Function SomethingElse(str1 As String, Optional str2 As String = "")
Dim someCode As String
someCode = str1
If str2 <> "" Then Application.Run str2
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Brilliant. Thanks Gerry, PHV and Combo. This will prove very helpful indeed.
 
Just tried it now. Oh dear.... i've got to go through all my code again with my new found knowledge of optional variables!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top