If statments in vba

  • Thread starter Thread starter rocky 123
  • Start date Start date
R

rocky 123

hello there,

I have created a system where =TODAY() brings up the correct date i
cell "A1", in cell "C1" a date is put in by the user. When the date i
cell "A1" is the same as "C1", then a messege box shows as a reminder
This works correctly. This is the code for it...
Range("A1").Select
If ActiveCell = Range("C1").Value Then
MsgBox "Date has reached"
End If

However when the word 'YES' is typed into cell "E1", I do not want thi
message box to come up when the dates match, can anybody please give m
some advice on how to do this part please?

Thankyou very much
Rocky
 
Rember with IF statements YES is not the same as yes or Yes.

You might also use lcase or ucase when testing E1


If ActiveCell = Range("C1").Value and range("e1").value<>"YES" then
MsgBox "Date has reached"
End If


or

If ActiveCell = Range("C1").Value and not(range("e1").value)="YES
then
MsgBox "Date has reached"
End If

or

If ActiveCell = Range("C1").Value then
if range("e1").value<>"YES" then
MsgBox "Date has reached"
End If
end if

or

If ActiveCell = Range("C1").Value then
if not(range("e1").value)="YES" then
MsgBox "Date has reached"
End If
end i
 
Hi,

How about this:

Range("A1").Select
If ActiveCell = Range("C1").Value _
And Range("E1") <> "YES" Then
MsgBox "Date has reached"
End If

good luck
jeff
 
rocky, here is one way
If Range("E1") = "yes" Then Exit Sub
Range("A1").Select
If ActiveCell = Range("C1").Value Then
MsgBox "Date has reached"
End If
--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 97 & 2000
** remove news from my email address to reply by email **
 
If Range("A1").Value = Range("C1").Value Then
MsgBox "Date has reached"
ElseIf Range("A1").Value = "YES" Then
MsgBox "A1 = Yes"
End If
 
Back
Top