Assign Sub Name to a Variable

A

Alan

If a string variable "ProductName" can have one of 10 values assigned
to it, is it possible to call a subroutine whose name is the same as
the value of the variable?? If so, can you supply an example please.
 
J

John

Hi Alan,

Not that I'm aware of, but you could pass the variable instead?........

Sub FirstProcedure()
Dim ProductName As String
Call ProcessingProcedure(ProductName)
End Sub

Sub ProcessingProcedure(ByVal ProductName As String)
Select Case ProductName
Case "Cat"
'Code here
Case "Dog"
'Code here
Case "Mouse"
'Code here
Case Else
'Code here
End Select
End Sub

Hope that helps

Best regards

John
 
B

Bob Phillips

Application.Run ProductName

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top