Excel 2010/2013 Excel 2007 Excel 2003 Tips & Tricks Excel Forum Course Index CIG Excel Book

 Home   News   Tips   Glossary   Templates   Forums   Help   Logon   Order   Contact Us More... What's New? Tips & Tricks Access Index Access Tips Excel Index Excel Tips Waiting List

 Tips & Tricks New Tips Added Weekly! Click here to get on our Mailing List

Number of Work Days
Use NETWORKDAYS to count the number of work days between two dates
Create a custom function in VBA to handle odd situations

 Q: I need to calculate the number of work days between two dates. I understand the NETWORKDAYS function allows me to calculate Monday thru Friday, but we also work on Saturdays. How can I count the number of days between two dates, but exclude all of the Sundays only? A: Very good question. Yes, you can use NETWORKDAYS if you only need to worry about excluding Saturdays, Sundays, and a list of holidays. However, if you have a custom requirement like yours, you'll need to write your own function using VBA. Here is the function I wrote. Note that in the video, the end of the first line of code says "as Date" but it should be "as Long". It works fine in both cases, but you should return a Long instead of a Date value. Public Function MyWorkDays(D1 As Date, D2 As Date) As Long   DayCount = 0   For X = D1 To D2     D = Weekday(X) '1=sun, 7=sat     If D <> 1 Then DayCount = DayCount + 1   Next X   MyWorkDays = DayCount End Function Here is a FREE video tutorial that shows you how to set up this function step-by-step:

By Richard Rost

 You may want to read these articles from the 599CD News:
 5/4/2014 Microsoft Access Expert 20 3/5/2013 Excel Tip: Price Markups 2/3/2013 Signed Copies of my Excel Book 9/27/2012 Excel Expert 10 Handbook Ready 9/18/2012 Two New Excel Tips: Date/Time Differences 6/20/2012 Excel Tip: Sum Cells Between Two Values 6/16/2012 New Excel Tip: Paste Link 3/26/2012 Excel Tip: 2D Matrix Lookups 11/18/2011 Dashboards in Excel 10/6/2011 Excel Expert 11 On Hold

Learn

 Access index Excel index Word index Windows index PowerPoint index Photoshop index Visual Basic index ASP index Seminars More...
Customers

Online Theater
Insider Circle
Student Databases
Info

Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Articles
Search Our Site
Waiting List
Production Schedule
Help

Live Chat
Customer Support
WalkThru Tutorials
Troubleshooting
FAQs
TechHelp
Consulting Services

Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
Order

Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact

Live Chat
General Info
Support Policy
Contact Form
Email Us