SELECT CASE "Jan-03" confusion

  • Thread starter Thread starter Craigm
  • Start date Start date
C

Craigm

Column M8 through M1800 is a date column and holds dates such a
"2/18/2003 9:28:00 AM" I would like to count the number of entries m
Month and Year.

I can change the format of the column but that only changes th
display. When I run the SELECT CASE below I get all zeros because th
date format for the CASE statement is still "2/18/2003 9:28:00 AM
even though "Feb-03" is displayed in the column.

-----------------------------
Columns("M:M").Select
Selection.NumberFormat = "[$-409]mmm-yy;@"

For Each rIncDate In Range("M8:M149") 'Need Last Row loop

Select Case rIncDate
Case "Jan-03"
iJan03 = iJan03 + 1
Case "Feb-03"
iFeb03 = iFeb03 + 1
Case Else
iOther = iOther + 1
End Select
Next rIncDate
 
minor change in the code




Columns("M:M").Select
Selection.NumberFormat = "[$-409]mmm-yy;@"

For Each rIncDate In Range("M8:M149") 'Need Last Row loop

Select Case format(rIncDate,"mmm-yy") 'change here
Case "Jan-03"
iJan03 = iJan03 + 1
Case "Feb-03"
iFeb03 = iFeb03 + 1
Case Else
iOther = iOther + 1
End Select
Next rIncDat
 
It is amazing how many grey cells I can kill.

Thank You. The fix you suggested works exactly as I needed
 
Back
Top