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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0

Forum statistics

Threads
1,214,545
Messages
6,120,132
Members
448,947
Latest member
test111

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