Case statement

S

smi

I am using Excel 97 with Win 95. I have a project with a lot of If and
ElseIf statement. It work but not very clean programming.
I am looking for Case statement example on the net.
Thank you for your time.

Long
 
C

Chip Pearson

A Select Case statement if quite simple, and fairly well documented in the
VBA help files. A simple example of Select Case is

Dim X As Integer
X = 3
Select Case X
Case 1
MsgBox "X=1"
Case 2
MsgBox "X=2"
Case 3
MsgBox "X=3"
Case Else
MsgBox "X = something else"
End Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 

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