ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   calculate weekdays only (https://www.excelbanter.com/excel-programming/310806-calculate-weekdays-only.html)

mike

calculate weekdays only
 
You can do this with formula or code. Which one is
necessary for your application?
-----Original Message-----
I am looking for code to insert yesterday's date if

yesterday was a weekday,
and to use the previous Friday's date otherwise (if

yesterday was Sunday).
Anyone know how to do this? Thanks.
.


benb

calculate weekdays only
 
I prefer to do it with code. Is there also an Excel function that does this
I am unaware of?

"Mike" wrote:

You can do this with formula or code. Which one is
necessary for your application?
-----Original Message-----
I am looking for code to insert yesterday's date if

yesterday was a weekday,
and to use the previous Friday's date otherwise (if

yesterday was Sunday).
Anyone know how to do this? Thanks.
.



Tom Ogilvy

calculate weekdays only
 
dtDate = Range(A1)-1-choose(Weekday(Range(A1).Value)-1,2,0,0,0,0,0,1)

--
Regards,
Tom Ogilvy


"benb" wrote in message
...
I prefer to do it with code. Is there also an Excel function that does

this
I am unaware of?

"Mike" wrote:

You can do this with formula or code. Which one is
necessary for your application?
-----Original Message-----
I am looking for code to insert yesterday's date if

yesterday was a weekday,
and to use the previous Friday's date otherwise (if

yesterday was Sunday).
Anyone know how to do this? Thanks.
.






All times are GMT +1. The time now is 03:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com