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
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,501
Messages
5,832,088
Members
430,110
Latest member
Chyke_mxl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top