Excel 2010
Excel 2007
Excel 2003
Tips & Tricks
Excel Forum
Course Index CIG Excel Book
 
Tutorials   News   Tips   Forums   Help   Logon   Order  
 
     
 
Tips & Tricks

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

   

  Access   Excel   Word   Windows   FrontPage   Hardware   Misc

 

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:
 
 Click here to view the FREE video

 

You may want to read these articles from the 599CD News:

 

 
Learn
 
Microsoft Access
Microsoft Excel
Microsoft Word
Microsoft Windows
Microsoft PowerPoint
Adobe Photoshop
Visual Basic
Active Server Pages
Online Seminars
More...
Customers
 
Account Login
Online Theater
Downloads
Lost Password
WalkThru Tutorials
Free Upgrades
Insider Circle
Info
 
Latest News
New Releases
User Forums
Tips & Tricks
Search Our Site
Waiting List
Production Schedule
Help
 
Live Chat
Customer Support
Troubleshooting
FAQs
TechHelp
Consulting Services
About Us
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Order
 
Video Tutorials
Handbooks
MYOLP Memberships
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Live Chat
General Contact Info
Support Policy
Contact Form
Email Us
Mailing Address
Phone Number
Fax Number
Course Survey
Try Us
 
Free Lessons
Online Theater
Mailing List
Course Indexes:   Microsoft Access   Microsoft Excel   Microsoft Word   Microsoft PowerPoint   Visual Basic (VB)   Photoshop   Active Server Pages (ASP)  
Keyword Search Cloud:   What's This?   courses   microsoft access tutorials   vlookup   access   cartesian   excel   dlookup   vba   attendance   access 2007   sql   windows 7   combo box   pivot table   visual basic   test   iif   word   calendar   query   conditional formatting   pivot tables   photoshop   hlookup   access 101   excel 202   excel 2007   student attendance   update query   my account   word 2007   append query   quickbooks   queries   dsum   reports   powerpoint   if   microsoft access   dmax   mail merge   relationships   ms access   access 2010   vb   dcount   subforms   excel 2003   handbooks   html   599cd   combobox   if function   security   microsoft word   after update  
Copyright 2012 by 599CD.com, All Rights Reserved