» Calculate a weeks start date 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
With the custom function below you can calculate the start date for any given week:
Function WeekStartDate(intWeek As Integer, intYear As Integer) As Date
Dim FromDate As Date, lngAdd As Long
If intYear < 1 Then intYear = Year(Date) ' the current year
FromDate = DateSerial(intYear, 1, 1)
If Weekday(FromDate, vbMonday) > 4 Then lngAdd = 7
WeekStartDate = FromDate + ((7 * intWeek) - 6) - _
Weekday(FromDate, vbMonday) + lngAdd
End Function
Book Store:
Recommended Books:
- The 22 Immutable Laws of Branding
- Special Edition Using Microsoft Excel 2002
- Marketing Plans That Work, Targeting Growth and Profitability
- Definitive Guide to Excel VBA
- Financial Statement Analysis with S&P insert card
- H&R Block's Just Plain Smart(tm) Tax Planning Advisor: A year-round approach to lowering your taxes this year, next year and beyond
No comments have been submitted.

