donlincolnmre2
Board Regular
- Joined
- Dec 23, 2006
- Messages
- 142
Hello
I’m looking to modify this macro which shows the date on upcoming Friday so in this case it will be 04/01/22
What I’m looking for is to place this Friday date in Cell A1 and then the macro will check every day for that day, so e.g if today is Tuesday and Friday is in future then the macro will just abort so same thing with wed and Thursday and If Friday is = to Friday then macro should also abort.
Once its Sat then the date in cell A1 is for Friday so the macro should put the new upcoming Friday date and keep checking as above for each day.
Below is the code.
Any help would be greatly appreciated.
Thanks.
Sub VBA_Find_Next_Friday_Method1()
Dim dNext_Friday As Date
dNext_Friday = DateAdd("d", -Weekday(Now) + 13, Now)
MsgBox "If today's date is '" & Format(Now, "DD MMM YYYY") & "' then" & vbCrLf & _
" Next Friday Date is : " & Format(dNext_Friday, "DD MMM YYYY"), vbInformation, "Next Friday Date"
End Sub
I’m looking to modify this macro which shows the date on upcoming Friday so in this case it will be 04/01/22
What I’m looking for is to place this Friday date in Cell A1 and then the macro will check every day for that day, so e.g if today is Tuesday and Friday is in future then the macro will just abort so same thing with wed and Thursday and If Friday is = to Friday then macro should also abort.
Once its Sat then the date in cell A1 is for Friday so the macro should put the new upcoming Friday date and keep checking as above for each day.
Below is the code.
Any help would be greatly appreciated.
Thanks.
Sub VBA_Find_Next_Friday_Method1()
Dim dNext_Friday As Date
dNext_Friday = DateAdd("d", -Weekday(Now) + 13, Now)
MsgBox "If today's date is '" & Format(Now, "DD MMM YYYY") & "' then" & vbCrLf & _
" Next Friday Date is : " & Format(dNext_Friday, "DD MMM YYYY"), vbInformation, "Next Friday Date"
End Sub