Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 144
Default comparing dates with code

Yes, that worked. Thanks Luke. This is my click.

Jack.

"Luke M" schreef in bericht
...
Using Mid returns a text string (note the quotation marks around the
date),
which won't compare properly with a Date (number). Use DateValue to
convert
string to date.

If DateValue(D) < Date Then ....
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Jack Sons" wrote:

Hi all,

I have this lines of code:

D = Mid(Range(Cells(rijrij, kolkol), Cells(rijrij, kolkol)), NN, 100)
If D < Date Then Range(Cells(rijrij + 20, kolkol), Cells(rijrij + 20,
kolkol)) = D

If the cursor hoovers over D I see a frame with yellow back ground and in
it:
D = "03 september 2009"
Hoovering over date shows a frame with yellow back ground and in it:
Date = 1-9-2009

The first line of code extracts the last part of a cell, that part is a
date.
I want to compare it with the date of today and if D is a day in the past
I
want to color that part of the cell content blue.
I used the second line not for the purpose of putting that date 20 rows
lower, but just to see if the comparison would work. It won't. I tried
with
formatting D as well as date, in a n umber of ways, but none was
successful.
What code do I need?

Your advice will be appreciated.

Jack Sons
The Netherlands





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
Comparing dates Gareth.Evans Excel Worksheet Functions 0 March 26th 09 08:54 AM
Comparing dates Gareth.Evans Excel Worksheet Functions 3 March 25th 09 07:05 PM
comparing two dates and executing code on condition ashish128 Excel Discussion (Misc queries) 4 August 31st 06 10:45 AM
Comparing 3 dates Steve Excel Worksheet Functions 1 May 9th 06 12:10 PM
Comparing dates Debbie F Excel Worksheet Functions 7 September 7th 05 11:57 AM


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

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

About Us

"It's about Microsoft Excel"