» Calculate the count of workdays between two dates using VBA in Microsoft Excel
VBA macro tip contributed by Erlandsen Data Consulting offering Microsoft Excel Application development, template customization, support and training solutions
CATEGORY - Custom Functions , Printing in VBA
VERSION - All Microsoft Excel Versions
Function GetWorkDays(StartDate As Long, EndDate As Long) As Long
' returns the count of days between StartDate - EndDate minus Saturdays and Sundays
Dim d As Long, dCount As Long
For d = StartDate To EndDate
If WeekDay(d, vbMonday) < 6 Then
dCount = dCount + 1
End If
Next d
GetWorkDays = dCount
End Function
Copy and paste the code into a normal module sheet.
The function can be used like this in a worksheet cell:
=GETWORKDAYS(A2;B2)
Cell A2 and B2 have to contain valid Excel dates, or formulas/functions that return dates, e.g. =TODAY().
The function does not count the holidays between the two dates.
Book Store:
Recommended Books:
- Preparing the Marketing Plan (Ama Marketing Toolbox Series New Edition)
- The 22 Immutable Laws of Marketing : Exposed and Explained by the World's Two
- Rich Dad's Guide to Investing: What the Rich Invest in, That the Poor and the Middle Class Do Not!
- Absolute Beginner's Guide to Microsoft Excel 2002
- Essentials of Investments with Standard & Poor's Educational Version of Market Insight + PowerWeb + Stock Trak Coupon
- Real Estate Loopholes: Secrets of Successful Real Estate Investing
No comments have been submitted.

