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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,008
Messages
6,122,672
Members
449,091
Latest member
peppernaut

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
Back
Top