Closed Thread
Results 1 to 2 of 2

Need Help- Trying to count unformatted dates (example: 12132011)

  1. #1
    Registered User
    Join Date
    12-14-2011
    Location
    Goleta, CA, USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Need Help- Trying to count unformatted dates (example: 12132011)

    Hello,

    I am trying to make a macro that will go through a range and count all cells that meet a criteria. I need the function to take a integer that represents a date and compare it to today. The dates are in a format of mmddyyyy such as 12132011 for today 1012012 for 1/1/2012. Below is the code that I have written:

    Sub getLate()
    Dim cnt As Integer
    Dim c As Range

    cnt = 0

    For Each c In Range(Range("F10"), Range("A9").End(xlDown).Offset(0, 6))
    If DateDiff("d", DateValue(Str(c.Value).Format("00-00-0000")), Date) >= 30 Then
    cnt = cnt + 1
    End If
    Next

    MsgBox cnt
    End Sub

    Any help will be greatly appreciated.

    Thank you!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: Need Help- Trying to count unformatted dates (example: 12132011)

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1