+ Reply to Thread
Results 1 to 2 of 2

Highlighting a row based on todays date

  1. #1
    Registered User
    Join Date
    12-12-2012
    Location
    Gosport
    MS-Off Ver
    Excel 2010
    Posts
    2

    Highlighting a row based on todays date

    Hello guys,

    Extremely new to this VBA programming of macros, I'm trying to highlight a row if todays date is within a particular range of a date stated in a column.
    e.g. if today's date is within 30 days of the date stated in column A i want to highlight the row yellow but if its within 15 days i would like to highlight it red.

    I would greatly appreciate any help which you genius's could give me.

    Many thanks,
    Jez1890

  2. #2
    Registered User
    Join Date
    12-12-2012
    Location
    Gosport
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Highlighting a row based on todays date

    Managed to find a solution to this:

    Dim LDate As Date
    Dim rRange As Range
    Dim Row As Object
    Dim DateValue As Date
    Dim lLastRow As Long
    Dim lLastColumn As Long

    Set rRange = Range("A2" & ":" & Range("A2").End(xlDown).Address)


    For Each Row In rRange.Rows

    If Row.Columns(1).Value <= DateAdd("d", 15, Date) Then
    Row.Interior.ColorIndex = 3

    ElseIf Row.Columns(1).Value <= DateAdd("d", 30, Date) Then
    Row.Interior.ColorIndex = 6

    End If

    Next

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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