Programming of alternative actions in VB macros

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Need help. I want a macro to run two alternative actions (not cell entries in
the worksheet) under the condition that in an Excel cell the entry is 1 or 0.
Can I write something like: if(cell=1, than jump to macro line 10, otherwise
jump to macro line 20)? What would be the syntax?
 
Hi

Sub test()
Select Case Sheets(1).Range("A1").Value
Case 0
MsgBox "Here's zero"
MsgBox "Not much, that"
Case 1
MsgBox "There's a one in there !"
MsgBox "we won"
Case Else
MsgBox "Nonsense in A1"
End Select
End Sub

HTH. Best wishes Harald
 

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

Back
Top