using if, then, else statments in a macro

  • Thread starter Thread starter Guest
  • Start date Start date
Karina,

Write code similar to the following

If some_test = True Then
do_something
Else
do_something_else
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
An example

Sub prntlbl()


Sheets("schedule").Select
If ActiveCell.Column <> 1 Then
MsgBox "you are in the wrong column to use this macro"
Exit Sub
Else
ActiveCell.Copy
Sheets("label").Select
Range("b1").Select
etcetc.....................

End If
End Sub
Regards
Bill K
 

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