Counting date occurances

  • Thread starter Thread starter Kim
  • Start date Start date
K

Kim

I have two columns P and R that contain both date information and numbers. I
want to count everytime a date is entered in the cell. Example

Apr-31 16-May
5 2
25-May 3
4 23-Jul

Does anyone know how I can do this?
 
Kim,

You could use a UDF.

Alt + F11 to open VB editor
Right click 'This Workbook' and insert module and paste this in

Function countdates(rng As Range)
For Each c In rng
If IsDate(c) Then countdates = countdates + 1
Next
End Function

Call from a worksheet cell with
=countdates(A1:A20)

Where A1:A20 is the range you want to check for dates.

Mike
 
I tried it and got a invalid procedure name

Mike H said:
Kim,

You could use a UDF.

Alt + F11 to open VB editor
Right click 'This Workbook' and insert module and paste this in

Function countdates(rng As Range)
For Each c In rng
If IsDate(c) Then countdates = countdates + 1
Next
End Function

Call from a worksheet cell with
=countdates(A1:A20)

Where A1:A20 is the range you want to check for dates.

Mike
 
Kim,

I can't replicate this error. Where does the error message occur and what
does it say in the worksheet cell where you have entered

=countdates(A1:A10)

Mike
 
Back
Top