Results 1 to 5 of 5

Macro to highlight rows based on workday dates

Threaded View

  1. #1
    Forum Contributor
    Join Date
    11-05-2006
    Posts
    123

    Macro to highlight rows based on workday dates

    I need to run a macro on a spreadsheet daily that contains dates in column G.

    If the date in this column matches today's date, highlight entire row color1. If it is one day before today's date, highlight rows color2. If it is tomorrow's date, highlight rows color3. I realize there are many ways this might be done, but my first approach went like this:

      
    FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
      
    For Each Cell In Range("G2:G" & FinalRow)
                If DateValue(Cell.Value) = DateValue(Date) Then
                    Cell.Interior.ColorIndex = 1
                ElseIf DateValue(Date) = DateValue(Date) - 1 Then
                    Cell.Interior.ColorIndex = 2
                ElseIf DateValue(Date) = DateValue(Date) + 1 Then
                    Cell.Interior.ColorIndex = 3
                End If
    Next Cell
    The problem with this is that Monday and Friday present a problem because Friday's date + 1 is Saturday; Monday's date - 1 is Sunday. The macro needs to include workday dates only, excluding weekend dates.
    I am attaching an example of what I would like the result to look like, assuming today was 11/14/2014, and you can see the format of the date I must work with. It accounts for 11/13, 11/14, & 11/17 (skips weekend of 15th, 16th).
    Attached Files Attached Files
    Last edited by Wedge120; 11-26-2014 at 10:18 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro for sorting rows based on dates in column G
    By Scotcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-03-2014, 10:12 AM
  2. Problem with macro that needs to find and highlight rows based on searching cells
    By mnk181 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2014, 12:24 PM
  3. macro to highlight rows based on column A
    By mugs62 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-28-2014, 07:20 AM
  4. VBA/Macro to delete rows based on comparing two dates?
    By tltlk678 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2012, 02:25 AM
  5. Workday Formula-Notice dates and Expiry dates
    By lamjoey in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-24-2011, 06:52 AM

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