VBA code to subtract on week days.

Zimmerman

Well-known Member
Joined
Jan 22, 2009
Messages
663
Can anybody help me out on subtracting week days with a VBA code. I'm trying to create a sheet that will tell the user when an item need something done with it. So they would type in a dtae on cell P2 and in cell P9 I'd like to have it subtract 7 week days from cell P2. But this will all be done by clicking a command button.

Windows XP
Excel 2003
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Are you able to create a worksheet formula to do what you want?

If so, then you can have the macro enter either the formula or the value returned from the formula.
 
Upvote 0
No i actually haven't thought of that. I guess i can try to figure this out in a formlua. Do you have an idea of how to start that. I can probably look that up if i have to.

Thanks
 
Upvote 0
OK i have the formula as follows.
=WORKDAY(P2,-6)
How could i get this into a VBA code?

Select a cell containing the formula.
Turn on the macro recorder.
Enter the formula in the cell.
Turn off the macro recorder.
Have a look at the code created.
 
Upvote 0
Sorry for being so blind to it all but that worked great thanks. One last thing that is no big deal but is there a way to not have the macro show up once it's run. meaning that if i click the cell where i recorded the macro and then run it, it shows the formula and i'd rather it didn't
 
Upvote 0
If you mean that you want the cell containing the formula to show the result of the formula only then :-

Code:
Selection=Selection.Value

This does the same as Copy/PasteSpecia/?Value
 
Upvote 0

Forum statistics

Threads
1,224,508
Messages
6,179,188
Members
452,893
Latest member
denay

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