Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default IF Statement

Hi people quick quest been a long time since i done this kind of thing

How would i program a excel docuement to say if it is the 1st then ad 2 days
and so on to go through the week but if it is a friday then i need to add 4
to miss out the weekend. really it would be good if the if statement would
work in MS Word.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default IF Statement

First you may find the weekday as below, assuming cell a1 has a
reference...

=weekday(a1)

Then passing on if function, to find if weekday=5(i.e., Friday), if
yes then, + 4

=IF(WEEKDAY(A1)=5,A1+4,A1+2)

Finally, to format it back as date, you may use text function...

The final formula as follows

=TEXT(IF(WEEKDAY(A1)=5,A1+4,A1+2),"mm/dd/yyyy")

I hope this helps.

Selva V Pasupathy
For more on Excel, VBA, and other resources
Please visit: http://socko.wordpress.com
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default IF Statement

Maybe you can find something on Chips web site. The link below takes you to
the index page. There are several entries under date.

http://www.cpearson.com/excel/topic.aspx

"Tech Support" wrote:

Hi people quick quest been a long time since i done this kind of thing

How would i program a excel docuement to say if it is the 1st then ad 2 days
and so on to go through the week but if it is a friday then i need to add 4
to miss out the weekend. really it would be good if the if statement would
work in MS Word.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default IF Statement

Here is a snippet that looks at the current date and determines the next work
day. If the current day is a Friday it will give Monday's date as the next
work day. Maybe you can use it to develop what you need.


Sub nextWorkDay()
myDate = Format(Now, "w")
MoDate = Format(Now, "d")
MoSchedDate = MoDate + 1
Select Case myDate
Case Is = 1
MoSchedDate = MoDate + 1
Case Is = 6
MoSchedDate = MoDate + 3
Case Is = 7
MoSchedDate = MoDate + 2
End Select
MsgBox "The next work day is " & MoSchedDate & " " & Format(Date,
"mmmm")
End Sub

"Tech Support" wrote:

Hi people quick quest been a long time since i done this kind of thing

How would i program a excel docuement to say if it is the 1st then ad 2 days
and so on to go through the week but if it is a friday then i need to add 4
to miss out the weekend. really it would be good if the if statement would
work in MS Word.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default IF Statement

The Excel way to do this (on the worksheet itself) would be to make use of
the Analysis ToolPak add-in...

=WORKDAY(A1,2)

This function also allows you to account for holidays via an optional 3rd
argument. But you said you wanted to be able to use the solution in Word
also... this means you want a VB solution. If the date you are adding your 2
"business" days to will never be a Saturday, you can use this statement...

Add2BusinessDays = DateIn + 2 - 2 * ((Weekday(DateIn) = 5) +
(Weekday(DateIn) = 6))

and if your date could be a Saturday, then you can use this statement
instead...

Add2BusinessDays = DateIn + 2 - 2 * ((Weekday(DateIn) = 5) +
(Weekday(DateIn) = 6) + 3 * (Weekday(DateIn) = 7))

Note: Your newsreader will surely word wrap those statements, but each one
should be on a single line.

--
Rick (MVP - Excel)


"Tech Support" wrote in message
...
Hi people quick quest been a long time since i done this kind of thing

How would i program a excel docuement to say if it is the 1st then ad 2
days
and so on to go through the week but if it is a friday then i need to add
4
to miss out the weekend. really it would be good if the if statement would
work in MS Word.


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
IF statement inside a SUMIF statement.... or alternative method Sungibungi Excel Worksheet Functions 3 December 4th 09 06:22 PM
Reconcile Bank statement & Credit card statement & accounting data Bklynhyc Excel Worksheet Functions 0 October 7th 09 09:07 PM
Embedding an OR statement in an IF statement efficiently Chatnoir11 Excel Discussion (Misc queries) 4 February 2nd 09 08:12 PM
Sum if statement with a left statement Eric D Excel Discussion (Misc queries) 4 July 23rd 08 05:31 PM
appending and IF statement to an existing IF statement spence Excel Worksheet Functions 1 February 28th 06 11:00 PM


All times are GMT +1. The time now is 11:31 PM.

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"