ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Write a sub to execute the following (https://www.excelbanter.com/excel-programming/328164-how-write-sub-execute-following.html)

Ronald Cayne

How to Write a sub to execute the following
 
If a2="" and c2="New"
Exit Subroutine
If a2="" and c2 not equal to the word New then continue executing the
subroutine



Stevie_mac

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





Patrick Molloy[_2_]

How to Write a sub to execute the following
 
IF Range("A2")= "" then
IF Range("C2")="New" Then
Exit Sub
Else
'do something else
End If
End if


"Ronald Cayne" wrote:

If a2="" and c2="New"
Exit Subroutine
If a2="" and c2 not equal to the word New then continue executing the
subroutine




Alan Beban[_2_]

How to Write a sub to execute the following
 
Ronald Cayne wrote:
If a2="" and c2="New"
Exit Subroutine
If a2="" and c2 not equal to the word New then continue executing the
subroutine


And if a2<""?

Alan Beban


All times are GMT +1. The time now is 09:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com