How to test range date.

gio123bg

Active Member
Joined
Feb 14, 2004
Messages
255
Hi to all!
I need to test, in a macro, this condition:

if sheet1.cell(1,1) > DATE1 and sheet1.cell(1,1) < DATE2 then ....

Where DATE1 is 12-02-2004 and DATE2 is 20-02-2004 for example.

In other words I need to test a cell "date".

Thanks.

Giovanni
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
hi!
try this
if worksheets(1).range("A1").value > DATE1 and worksheets(1).range("A1").value < DATE2 then
'do conditions here if true
end if
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

Try this.

Tony

Sub bbb()
DATE1 = DateValue("12/2/2004")
DATE2 = DateValue("20/2/2004")
If DateValue(Range("a1")) > DATE1 And DateValue(Range("a1")) < DATE2 Then
MsgBox "YES"
Else
MsgBox "NO"
End If

End Sub
 

gio123bg

Active Member
Joined
Feb 14, 2004
Messages
255
Thanks, but I have the necesity to have two indexes (row and column) and the format in my cell is "date" selected how "dd-mm-yyyy".
My you send me un example for my situation?
Thanks.

Giovanni
 

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
OK!
let me try again.
if worksheets(1).range(cells(rowx,colx)).value > DATE1 and worksheets(1).range(cells(rowx,colx)).value < DATE2 then
end if

Does this work for you?
 
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,152,161
Messages
5,768,539
Members
425,480
Latest member
br400821

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