Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default adding days from one cell with a date in it to another cell

i have a spredsheet where i put a date in one cell and i want it to add 5days
..6.7.8.etc up to 15 days but i dont want it to include sundays is this
possible

for example start date 01/07/09 add 15 days not including sundays finish
date will be 17/07/09

I also have one that needs to discount saturday and sunday
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,440
Default adding days from one cell with a date in it to another cell

Look in HELP for the WORKDAY() function

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"cufc1210" wrote in message
...
i have a spredsheet where i put a date in one cell and i want it to add
5days
.6.7.8.etc up to 15 days but i dont want it to include sundays is this
possible

for example start date 01/07/09 add 15 days not including sundays finish
date will be 17/07/09

I also have one that needs to discount saturday and sunday


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default adding days from one cell with a date in it to another cell

Assuming start date is in A2, number of days to add is in A3:

The WORKDAY function will work for your 2nd crtieria.
=WORKDAY(A2,A3)

For your first scneario, where you want to exclude Sundays, you'll need this
UDF. Open VBE (Alt+F11) then goto Insert - Module, and paste this in.

'===========
Function NoSunday(StartDate As Date, _
AddDays As Integer) As Date
Dim xFinish As Date
Dim xDays As Integer
xFinish = StartDate + AddDays

xDays = 1
Do Until xDays = 0
xDays = 0
For i = StartDate To xFinish
'If a sunday is found, extend finish date
If WorksheetFunction.Weekday(i) = 1 Then
xDays = xDays + 1
End If
Next
StartDate = xFinish
xFinish = xFinish + xDays
Loop

NoSunday = xFinish
End Function
'=================


Close out VBE. Back in your workbook, your formula becomes:
=NoSunday(A2,A3)
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"cufc1210" wrote:

i have a spredsheet where i put a date in one cell and i want it to add 5days
.6.7.8.etc up to 15 days but i dont want it to include sundays is this
possible

for example start date 01/07/09 add 15 days not including sundays finish
date will be 17/07/09

I also have one that needs to discount saturday and sunday

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default adding days from one cell with a date in it to another cell


cufc1210;456656 Wrote:
i have a spredsheet where i put a date in one cell and i want it to add
5days
..6.7.8.etc up to 15 days but i dont want it to include sundays is
this
possible

for example start date 01/07/09 add 15 days not including sundays
finish
date will be 17/07/09

I also have one that needs to discount saturday and sunday


If you add 15 days to 1/7/2009, not including Sundays then I make that
18/7/2009 (unless you are including the start date)

To do that with a formula you can use

=A1-WEEKDAY(A1,3)+INT(7/6*(B1+MIN(5,WEEKDAY(A1,3))))

where A1 is the start date and B1 the number of days to add, e.g. 15

If you want to include the start date then change references to A1 to
A1-1 i.e.

=A1-1-WEEKDAY(A1-1,3)+INT(7/6*(B1+MIN(5,WEEKDAY(A1-1,3))))


--
barry houdini
------------------------------------------------------------------------
barry houdini's Profile: http://www.thecodecage.com/forumz/member.php?userid=72
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=126400

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default adding days from one cell with a date in it to another cell

thanks guys that a great help

Just one thing barry houdini that formula works great except when i put in a
date for monday

e.g. 3rd Aug 09 the return date is 20th aug 09 when it should be 19th aug 09
every other date from tuesday to saturday works fine any ideas

Cheers

cufc1210

"barry houdini" wrote:


cufc1210;456656 Wrote:
i have a spredsheet where i put a date in one cell and i want it to add
5days
..6.7.8.etc up to 15 days but i dont want it to include sundays is
this
possible

for example start date 01/07/09 add 15 days not including sundays
finish
date will be 17/07/09

I also have one that needs to discount saturday and sunday


If you add 15 days to 1/7/2009, not including Sundays then I make that
18/7/2009 (unless you are including the start date)

To do that with a formula you can use

=A1-WEEKDAY(A1,3)+INT(7/6*(B1+MIN(5,WEEKDAY(A1,3))))

where A1 is the start date and B1 the number of days to add, e.g. 15

If you want to include the start date then change references to A1 to
A1-1 i.e.

=A1-1-WEEKDAY(A1-1,3)+INT(7/6*(B1+MIN(5,WEEKDAY(A1-1,3))))


--
barry houdini
------------------------------------------------------------------------
barry houdini's Profile: http://www.thecodecage.com/forumz/member.php?userid=72
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=126400


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date in cell + 77 days Mark Excel Worksheet Functions 2 February 5th 09 02:19 PM
Date Turns Green 90-Days before the date shown in cell ajaminb Excel Worksheet Functions 7 September 28th 08 11:36 PM
Adding days to a date cell to get a new date Pete Derkowski Excel Worksheet Functions 6 May 1st 08 03:53 PM
How to put todays date in one cell then the next cell adds x days trekkies Excel Discussion (Misc queries) 1 January 6th 06 04:26 AM
formula to calculate future date from date in cell plus days Chicesq Excel Worksheet Functions 8 November 3rd 05 12:25 PM


All times are GMT +1. The time now is 12:37 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"