» 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:
- Microsoft Office XP Step-By-Step (With CD-ROM)
- VBA for Modelers: Developing Decision Support Systems Using Microsoft« Excel
- Flipping Properties: Generate Instant Cash Profits in Real Estate
- What the IRS Doesn't Want You to Know: A Cpa Reveals the Tricks of the Trade
- Your First Business Plan: A Simple Question and Answer Format Designed to Help You Write Your Own Plan (3rd Ed)
- Business Plans Kit for Dummies (With CD-ROM)
No comments have been submitted.

