+ Reply to Thread
Results 1 to 5 of 5

Macro to highlight rows based on workday dates

  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:

    Please Login or Register  to view this content.
    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.

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Macro to highlight rows based on workday dates

    Hi Wedge120,

    Try to use conditional formatting (see attachment)
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    09-26-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Macro to highlight rows based on workday dates

    Hello Wedge120,

    Did you have a look at the Weekday() function?
    This will give you back a numeric value of the day in the week, by default 1 is sunday.

    Following code must work (didn't test it):
    Please Login or Register  to view this content.
    Cheers,
    Demeter

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

    Re: Macro to highlight rows based on workday dates

    Demeter,

    That works nicely, though your ELSEIF statements contain:
    Please Login or Register  to view this content.
    where they should be

    Please Login or Register  to view this content.
    Without this correction, the code doesn't work as expected.

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

    Re: Macro to highlight rows based on workday dates

    Quote Originally Posted by nilem View Post
    Hi Wedge120,

    Try to use conditional formatting (see attachment)
    I figured there was a way to do this, but I don't quite follow what your doing. The language is Hebrew or something else?

+ Reply to Thread

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