select case arguments

C

c1802362

I am trying to use a text string in a select case statement in VBA. To
wit:


Select Case test_string

Case Is = "first header"
statement 1

Case Is = "second header"
statement 2

etc

End Select

I've been trying (without luck) to get VBA to recognize the text
string.

Any suggestions?

Art
 
M

Mike Middleton

c1802362 or Art -

What is the text string test_string? Where is it defined and how?

For example, in a standard module, this works:

Sub test()
test_string = "first header"
Select Case test_string
Case Is = "first header"
MsgBox "First Header"
Case Is = "second header"
MsgBox "Second Header"
End Select
End Sub

- Mike Middleton
http://www.DecisionToolworks.com
Decision Analysis Add-ins for Excel
 

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