Fifteen Days From Today's Date, (Not Counting Saturday & Sunday).
I am just starting to learn VBA. I have a good book, and I search the 'net for examples to go by.
Ultimately, I want a Macro to add fifteen week-days to the current date and display the date in this format: 07-21-2017. -Not including Saturday and Sunday.
But I am stuck with a compile error. It says "Object Required" and it highlights:
Set iCounter = 0
All the examples I have seen make the counter an integer, and I have studied data objects. But can you make an object an integer?
Here's what I have written so far:
Sub Macro4()
'
' Macro4 Macro
'
'
Dim fifteenDaysFromNow As Date
Dim iCounter As Integer
'This next line is highlighted with the compile error
Set iCounter = 0
Dim day As DayOfWeek
Set DayOfWeek = currentDateTime.DayOfWeek
Do
fifteenDaysFromNow = DateAdd("d", 1, Date)
If day = DayOfWeek.Saturday Or day = DayOfWeek.Sunday Then
iCounter = -1
Else
iCounter = +1
Loop While iCounter <= 16
End If
End Sub
|