View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Stevie_mac Stevie_mac is offline
external usenet poster
 
Posts: 39
Default How to Write a sub to execute the following

Public Sub DoSomething()
If ActiveSheet.Range("A2").Text = "" and ActiveSheet.Range("A2").Text = "New" Then Exit Sub
If ActiveSheet.Range("A2").Text = "" and not (ActiveSheet.Range("A2").Text = "New") Then
'Do stuff
End if
End Sub

NOTE: however, 1 1st IF is not necessary because if the 2nd IF is true, the 1st IF must be false

'This is all that is needed to satisfy your critira (unless you intend to do other combination checks, then go with the
1st solution)
Public Sub DoSomething()
If ActiveSheet.Range("A2").Text = "" and not (ActiveSheet.Range("A2").Text = "New") Then
'Do stuff
End if
End Sub

PS, watch for line breaks in the code samples above;
If ...blah...blah.... Then should be on 1 line.


"Ronald Cayne" wrote in message ...
If a2="" and c2="New"
Exit Subroutine
If a2="" and c2 not equal to the word New then continue executing the
subroutine