how to convert to VBA - Weekending date

Bryan123

New Member
Joined
May 23, 2019
Messages
41
im trying to create a code to get the weekending date. However, there is an error when i try to run it.

=A1+(7-WEEKDAY(A1)) - this is the code i'd like to convert to vba


WE.Value = transdate.Value + (8 - Weekday(transdate.Value))
-----****Note
WE.value is a textbox where the weekending date should be recorded. transdate.value is the transaction date.
Please assist.
Thanks
Bryan
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try something like:
Code:
[COLOR=#333333]WE.Value = transdate.Value + (7 - Application.WorksheetFunction.Weekday(transdate.Value))[/COLOR]
 
Upvote 0
Hi,
thanks for the quick revert. I still have error - Unable to get the weekday property of the worksheetfuction class. I dont know where to position that code. My program when run, will automatically fill in the transdate and what i would like to achieve is also fill in the Weekending date from the transdate. Dont know where to put it.
Thank you
Bryan
 
Upvote 0
Try commenting out that line of code, and add these lines and let me know what they return:
Code:
MsgBox transdate.Value
MsgBox IsDate(transdate.Value)
 
Upvote 0

Forum statistics

Threads
1,224,821
Messages
6,181,163
Members
453,021
Latest member
Justyna P

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