LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default Count Dates in a range

I'm, trying to count dates in a column to determine the number of dates after
the current date in order to present the user with a messge to check for
overdue jobs and the number of jobs due today, when the sheet is opened or
activated. I testing the following code:

Sub CountDates()

Dim Dt As Date

Dt = Date ' todays date

With Worksheets("Jobs")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row 'last row of job data
End With

Set StartCell = Range("Q4") ' starting range
Set Endcell = Range("Q" & LastRow) 'ending range
oDue = Application.WorksheetFunction.CountIf(Range(StartC ell, Endcell), "<"
& Dt) 'counts the number of dates earlier than today

MsgBox oDue & " Jobs are overdue"

End Sub

I have ensured that the dates are entered in each cell as a date dd/mm/yyy.
The result is always 0 using "<" or "". If text is entered in the range (a
heading) it returns a positive count with "" but not "<". Strangley
Application.WorksheetFunction.CountIf(Range(StartC ell, Endcell), Dt) counts
the correct number of dates = to Dt.

The result I'm looking for is a message "There are N jobs due today and N
jobs are overdue".

I'm using XL2007

Any ideas or other solutions
--
Jim
 
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
count number of dates in range Sunflower[_3_] Excel Worksheet Functions 2 March 24th 10 06:07 PM
How do I count a range of dates in a column? GBC Excel Worksheet Functions 6 February 24th 09 07:10 PM
How do I get a count of dates within a range..? cmharri123 Excel Worksheet Functions 2 February 1st 06 11:22 AM
How do I count in a range of dates? nancy Excel Worksheet Functions 2 November 23rd 05 11:03 AM
How to count dates within a certain range in a column with mutiple date range entries Krisjhn Excel Worksheet Functions 2 September 1st 05 01:59 PM


All times are GMT +1. The time now is 12:05 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"