![]() |
Change text to date and check against date in cell
I have the following:
qryMonth and qryYear are passed from a form. CDt3 = ((qryMonth) & "/1/" & qryYear) If WshD.Range("M65536").End(xlUp) CDt3 Then .... The data in the Range is a date (also formatted as a date) If the Range is 9/1/05 and CDt3 = 10/1/05 the If statement does not see CDt3 as being greater. What needs to be done to CDt3 so that it works properly? I did try: NValue = FormatDateTime(CDt3) and used NValue in the IF statement without success. Thanks for any help. |
Change text to date and check against date in cell
How about using Cdate function like
If WshD.Range("M65536").End(xlUp) Cdate(CDt3) Then keizi "RW" wrote in message ... I have the following: qryMonth and qryYear are passed from a form. CDt3 = ((qryMonth) & "/1/" & qryYear) If WshD.Range("M65536").End(xlUp) CDt3 Then ... The data in the Range is a date (also formatted as a date) If the Range is 9/1/05 and CDt3 = 10/1/05 the If statement does not see CDt3 as being greater. What needs to be done to CDt3 so that it works properly? I did try: NValue = FormatDateTime(CDt3) and used NValue in the IF statement without success. Thanks for any help. |
Change text to date and check against date in cell
You could try something like this; CDt3 = DateSerial( qryYear, qryMonth, 1 ) If ( DateDiff( "d", CDt3, WshD.Range("M65536").End(xlUp) ) 0 ) Then -- fazstp ------------------------------------------------------------------------ fazstp's Profile: http://www.excelforum.com/member.php...o&userid=30574 View this thread: http://www.excelforum.com/showthread...hreadid=507486 |
Change text to date and check against date in cell
kounoike and fazstp,
Thanks for helping. Both options work! "fazstp" wrote: You could try something like this; CDt3 = DateSerial( qryYear, qryMonth, 1 ) If ( DateDiff( "d", CDt3, WshD.Range("M65536").End(xlUp) ) 0 ) Then -- fazstp ------------------------------------------------------------------------ fazstp's Profile: http://www.excelforum.com/member.php...o&userid=30574 View this thread: http://www.excelforum.com/showthread...hreadid=507486 |
All times are GMT +1. The time now is 03:36 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com