ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Date checking code (https://www.excelbanter.com/excel-programming/291866-help-date-checking-code.html)

Mr. Clean[_2_]

Help with Date checking code
 
How would I change
this condidtion to check for a value
whe

PLEXP is = Date and
the Month of PLEXP is <= Next Month

Also taking into consideration a Dec/Jan
value combination. (PLEXP Month is Dec)

If ((DateValue(PLEXP) = Date) And _
(DatePart("M", DateValue(PLEXP)) <= _
(DatePart("M", Date) + DatePart("M", Date) + 1))) Then

I can't quite get it right. Not used to VBA.

Tom Ogilvy

Help with Date checking code
 
If ((DateValue(PLEXP) = Date) And _
(DateValue(PLEXP) <= _
DateSerial(year(Date),Month(Date)+2,0)) Then

I think you would run into problems at for the Dec Jan time frame if you
just check on Month, so This checks if the PLEXP is <= the last day of the
next month. I believe that will achieve your ends.

--
Regards,
Tom Ogilvy


"Mr. Clean" wrote in message
om...
How would I change
this condidtion to check for a value
whe

PLEXP is = Date and
the Month of PLEXP is <= Next Month

Also taking into consideration a Dec/Jan
value combination. (PLEXP Month is Dec)

If ((DateValue(PLEXP) = Date) And _
(DatePart("M", DateValue(PLEXP)) <= _
(DatePart("M", Date) + DatePart("M", Date) + 1))) Then

I can't quite get it right. Not used to VBA.




Mr. Clean[_2_]

Help with Date checking code
 
In article ,
says...
If ((DateValue(PLEXP) = Date) And _
(DateValue(PLEXP) <= _
DateSerial(year(Date),Month(Date)+2,0)) Then

Thanks, That works great...


All times are GMT +1. The time now is 09:13 AM.

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