macro runs only if cell not blank

  • Thread starter Peterzh193 via OfficeKB.com
  • Start date
P

Peterzh193 via OfficeKB.com

want a macro that refuses to run if cell E3 is blank/empty

to run the macro correcty data must be in this cell but it is user error that
may leave it blank.....can i avoid this with a question (msgbox) as part of a
macro?
 
J

JLGWhiz

You can use an If...Then statement to control the macro.

Sub runMacro()
If Range("E3") = "" Then
Exit Sub
End If
'The rest of your macro here
End Sub
 
Top