+ Reply to Thread
Results 1 to 2 of 2

Need help comparing dates

Hybrid View

aben8057 Need help comparing dates 08-31-2006, 03:22 PM
Guest Ok, I'm not sure on exactaly... 08-31-2006, 05:16 PM
  1. #1
    Registered User
    Join Date
    08-31-2006
    Posts
    1

    Need help comparing dates

    Hello group, first of all great site. I find myself with a challenge and am greatful for any assistance that you could provide.

    Background:
    We have a database running in the background that pushes out dates into excel where management can generate automaticlly.

    Objective:
    I need to create a macro the compares a row of dates against todays date (date when report is generated) and outputs a colored filled cell. We are currently managing this spreadsheet by changing the colored cell filled manually. Ideally I would like to have this aspect automated.

    Specifications:
    Compare the dates in a row against today (date report generated) and if the date is up to 7 days late, auto fill a status cell in yellow. If the autopopulated date in the cell exceeds 7 days then status cell is then red.

    eg: if report generated on Aug-31-06 and cell is populated by Sept-1-06 then status color should be yellow. If date is Sept-10-06 then status color is red.


    Any assistance would be appreciated..thanking you in advance
    Attached Images Attached Images

  2. #2
    mpeplow
    Guest
    Ok, I'm not sure on exactaly what you are tying to do but lets assume that you want to compare all of dates from column C to todays date and have cell Q changed to the red if more than 7 days has passed and green if it has been 7 days or less. Then you would use something like this. This should give you an idea of where to start.

    Sub Change_Colors()
    Dim First_Date As Date
    Dim Second_Date As Date
    Dim Difference As Long
    Dim FinalRow As Long
    FinalRow = Range("C65535").End(xlUp).Row

    Second_Date = Date

    For i = 1 To FinalRow
    Range("C" & i).Select
    First_Date = Selection.Formula
    Difference = DateDiff("d", First_Date, Second_Date)
    If Difference > 7 Then
    Range("Q" & i).Interior.ColorIndex = 3
    Else
    Range("Q" & i).Interior.ColorIndex = 10
    End If
    Next i
    End Sub

+ Reply to 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