Add coding to check day of the week

zoog25

Active Member
Joined
Nov 21, 2011
Messages
418
Hello all,

I have a coding that adds appointments to the outlook calendar. The situation is that i have a date in a cell. The coding would then make an appointment 90 days from the date entered. The issue is, what do i add to the coding so in case the 90 days falls on a Saturday or Sunday, it moves it to the following Monday. Ie, if the 90 days falls on September 21 or September 22 (Saturday or Sunday), the coding would make the appointment for September 23 or Monday.

Code:
dStartTime = (TPws.Cells(rw, "AD").Value + 90) + #8:00:00 AM#

This is all i have. AD is the date entered in the spreadsheet and i just add 90. Now what do i add to check to see that that date isn't on a Saturday or Sunday and if it is, it moves it to Monday.

Thank you.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi zoog25,

Try this:

Code:
If Weekday(dStartTime, vbMonday) = 6 Then 'Saturday
    dStartTime = (TPws.Cells(rw, "AD").Value + 90 + 2) + #8:00:00 AM#
ElseIf Weekday(dStartTime, vbMonday) = 7 Then 'Sunday
    dStartTime = (TPws.Cells(rw, "AD").Value + 90 + 1) + #8:00:00 AM#
End If

I have a coding that adds appointments to the outlook calendar.

If you could post your entire code it would be appreciated as I'm sure setting appoints via Excel would be useful to at least some users in the community.

Thanks,

Robert
 
Upvote 0
If I have understood correctly, I think this should do it for you directly.
Code:
dStartTime = WorksheetFunction.WorkDay(TPws.Cells(rw, "AD").Value + 89, 1) + #8:00:00 AM#
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top