VBA-Excel: Get all the WeekDays or Working days in Specified Date Range, (excluding Satudays and Sundays)
This tutorial will teach you how to get all the working days or weekdays in a specified date range(excluding Satudays and Sundays), simple but very useful when you have come up with a excel where you have to work with all the business working days.
If the date range is mentioned between 8-Jan-2014 to 20-Jan-2014 then working days the working days will be
Sub FnDateAdd() Dim strDate Dim mainWorkBook As Workbook Dim intCounter intCounter = 1 Set mainWorkBook = ActiveWorkbook For i = Date To DateAdd("m", 1, Date) strDay = Format(i, "dddd") If strDay <> "Saturday" And strDay <> "Sunday" Then mainWorkBook.Sheets("Sheet1").Range("A" & intCounter) = i mainWorkBook.Sheets("Sheet1").Range("B" & intCounter) = strDay intCounter = intCounter + 1 End If Next End Sub
Navigate through all the Dates using a loop, check each date’s day and print it , if it is either of ‘Saturday’ or ‘Sunday’ then just ignore it, simple right J