Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
RW RW is offline
external usenet poster
 
Posts: 49
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
RW RW is offline
external usenet poster
 
Posts: 49
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 make 1 date cell automatically change another date cell Scotty Excel Worksheet Functions 4 April 22nd 10 09:01 AM
CHANGE TEXT DATE TO NUMERIC DATE slf Excel Worksheet Functions 5 January 5th 10 10:20 AM
date in Cell to change colors if the date is beyond today's date Pete Elbert Excel Discussion (Misc queries) 2 June 6th 09 06:31 AM
how do i change text format date to date (i.e., mm/yy to mm/dd/yyy lindsey Excel Discussion (Misc queries) 1 July 27th 07 10:05 PM
Change a date in text format xx.xx.20xx to a recognised date format concatenator Excel Programming 1 November 24th 03 11:33 PM


All times are GMT +1. The time now is 05:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"