ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dats in If statement (https://www.excelbanter.com/excel-programming/388186-dats-if-statement.html)

Janos

Dats in If statement
 
just a quick one, I am trying to count stuff within a month, This If
statement counts if it is an April date:

If r1.Value "1/4/2007" And r1.Value < "31/04/2007" Then
counter = counter + 1
Address2 = r1.Offset(1, 0).Address(ReferenceStyle:=xlR1C1)
End If

This works fine, but:

If r1.Value "1/5/2007" And r1.Value < "31/05/2007" Then
counter = counter + 1
Address2 = r1.Offset(1, 0).Address(ReferenceStyle:=xlR1C1)
End If

Lets through all sort of dates... including june and what not...

Am i going blind? or just plainly stupid? What am idoing wrong?

Thank you all!

Janos

Bob Phillips

Dats in If statement
 
Play safe

If r1.Value DateSerial(2007,5,1) And r1.Value < DaterSerial (2007,6,1)

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Janos" wrote in message
...
just a quick one, I am trying to count stuff within a month, This If
statement counts if it is an April date:

If r1.Value "1/4/2007" And r1.Value < "31/04/2007" Then
counter = counter + 1
Address2 = r1.Offset(1, 0).Address(ReferenceStyle:=xlR1C1)
End If

This works fine, but:

If r1.Value "1/5/2007" And r1.Value < "31/05/2007" Then
counter = counter + 1
Address2 = r1.Offset(1, 0).Address(ReferenceStyle:=xlR1C1)
End If

Lets through all sort of dates... including june and what not...

Am i going blind? or just plainly stupid? What am idoing wrong?

Thank you all!

Janos





All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com