Usinf VBA to run a IF/AND statement

scrandal

Board Regular
Joined
Jul 15, 2004
Messages
160
How do I write a VBA IF statement that includes a AND section. The code below is what I tried and it didn't work. Any suggestions?

If Now() >= #12/1/2005# And Now() < #12/4/2004# Then
Msg Box "Message to user"
End If
 

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Smitty

Legend
Joined
May 15, 2003
Messages
29,536
How's this:
Code:
    If Now >= #12/1/2005# And Now < #12/31/2005# Then
        MsgBox "Message to user"
    End If
But how could your test evaluate correctly? >= 12/1/2005 AND < 12/4/2004?

Hope that helps,

Smitty
 

scrandal

Board Regular
Joined
Jul 15, 2004
Messages
160
That was a typo on my post, I had it my code as 2005. I tried it a again and it seemed to work with a minor tweek. Thanks for the quick response.

Steve
 

Watch MrExcel Video

Forum statistics

Threads
1,118,910
Messages
5,574,994
Members
412,633
Latest member
simon_elvin
Top