I have the following udf that returns a 1d array of dates for specific date excluding Friday & Saturday
Code: Select all
Sub Test()
Dim a
a = ListDates(Range("A1").Value)
End Sub
Public Function ListDates(ByVal inputDate As Date) As Variant
Dim outputArray() As Variant, currentDate As Date, i As Long
ReDim outputArray(1 To 31)
currentDate = DateSerial(Year(inputDate), Month(inputDate), 1)
i = 1
Do While Month(currentDate) = Month(inputDate)
If Weekday(currentDate) <> vbFriday And Weekday(currentDate) <> vbSaturday Then
outputArray(i) = currentDate
i = i + 1
End If
currentDate = currentDate + 1
Loop
ReDim Preserve outputArray(1 To i - 1)
ListDates = outputArray
End Function
What I need is to return the 1d array so as to start with Sunday all the time. so in this case the first item in the output array should be empty.
Also the second item should be empty. Also the third item should be empty. The fourth item should have the first date which is 1/11/2023 (wednesday)
Hope my problem is clear.