Sub WeekDays_Only()
'Modified 10/5/2018 9:27:42 PM EDT
Dim i As Long
Dim aa As Long
Dim x As Long
Dim n As Integer
Dim StartDate As Date
Dim StopDate As Date
On Error GoTo M
StartDate = InputBox("Enter Start Date", "Enter Like this 12/18/2018")
StopDate = InputBox("Enter Stop Date", "Enter Like this 12/18/2018")
n = DateDiff("d", StartDate, StopDate)
For i = 1 To n
ans = DateAdd("d", i - 1, StartDate)
aa = Weekday(ans)
If aa <> 7 And aa <> 1 Then
x = x + 1
Cells(x, 1).Value = ans
End If
Next
With Columns(1)
.NumberFormat = "DDDD,MMMM,DD,YYYY"
.Font.Size = 16
.AutoFit
.HorizontalAlignment = xlLeft
End With
Exit Sub
M:
MsgBox "You enter a improper date"
End Sub
Yes. Here are 3 methods.Hello!
Is there a quick way to generate a list of the weekday dates between a starting and an ending date? Without weekends?
Thanks!
Excel Workbook | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Start | 27/09/2018 | 27/09/2018 | ||
2 | End | 18/10/2018 | 28/09/2018 | ||
3 | 1/10/2018 | ||||
4 | 2/10/2018 | ||||
5 | 3/10/2018 | ||||
6 | 4/10/2018 | ||||
7 | 5/10/2018 | ||||
8 | 8/10/2018 | ||||
9 | 9/10/2018 | ||||
10 | 10/10/2018 | ||||
11 | 11/10/2018 | ||||
12 | 12/10/2018 | ||||
13 | 15/10/2018 | ||||
14 | 16/10/2018 | ||||
15 | 17/10/2018 | ||||
16 | 18/10/2018 | ||||
Weekdays |
Sub ListWeekdays()
Dim i As Long
Dim dStart As Date, dEnd As Date
dStart = Range("B1").Value - 1
dEnd = Range("B2").Value
Do
i = i + 1
Range("C" & i).Value = WorksheetFunction.WorkDay(dStart, i)
Loop Until WorksheetFunction.WorkDay(dStart, i + 1) > dEnd
End Sub
Excel 2010 | |||||
---|---|---|---|---|---|
A | B | C | |||
1 | Start | Thu 27-Sep-18 | Thu 27-Sep-18 | ||
2 | End | Thu 18-Oct-18 | Fri 28-Sep-18 | ||
1a |
Cell Formulas | ||
---|---|---|
Range | Formula | |
C1 | =WORKDAY.INTL(B1-1,1,1) | |
C2 | =IF((C1+1)<=$B$2,WORKDAY.INTL(C1,1,1),"") |
DaveCopy C2 down