View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
kounoike[_2_] kounoike[_2_] is offline
external usenet poster
 
Posts: 126
Default 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.