Date plus one workday in macro

I have a macro that uses "Date" and "Now()" to evaluate date columns in the data. For example, if the date in the row is today, the macro colors that date cell blue. What I would like is to have the code change the cell to blue if the date is tomorrow (instead of today). There are enough instances where I thought rather than re-writing all the code, I could just change "Date" to "Date plus one workday" and "Now()" to either "Now() plus one workday" or use "Date plus one workday" instead.

Looks like "Date + 1" would certainly increment the date the code is working from but I can't find a good example on google of the syntax for a "Date + 1 networkday"

Also was wondering if I could just specify "date=date+1 networkday" at the begining so I wouldn't have to change all the instances of "Date".

Thanks in advance,

swjtx99
swjtx99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ejgil HedegaardCommented:
Here is a function to calculate the next working day.
It can be used in VBA calls, or as a function in a cell.
When used as a cell function the code must be placed in a regular module, not a worksheet module.

I have described different ways to set the holiday list, delete what you don't want, all does the same and just for test have Monday 8/11/2014 and Tuesday 8/12/2014 as holidays.
See file.

Function NextNetWorkDay(d As Date) As Date
    Application.Volatile    'When function is used as a function in a cell, means the function runs on every calculation
    Dim Holidays(), i As Integer
    
    'Defining the holidays list
    'A range on the sheet
        Holidays = Range("D2:D3")
    'A named range on the sheet
        Holidays = Range("Holidays")
    'or
        Holidays = [Holidays]
    
    'An array with the serial numbers of the dates
        Holidays = Array(41862, 41863)
    'or using dates as input, converted to serial numbers
        Holidays = Array(CLng(DateSerial(2014, 8, 11)), CLng(DateSerial(2014, 8, 12)))
    'or as dates, US format month/day/year, converted to serial numbers
        Holidays = Array(CLng(#8/11/2014#), CLng(#8/12/2014#))
    
    Do
        i = i + 1
        If WorksheetFunction.NetworkDays(d + i, d + i, Holidays) = 1 Then
            NextNetWorkDay = d + i
        End If
    Loop Until NextNetWorkDay > 0
End Function

Open in new window

Next-working-day.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
swjtx99Author Commented:
Thanks! I think I can use this for what I need.

Thanks again for your help,

swjtx99
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Spreadsheets

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.