If statement

G

Guest

I need help with a formula/macro. I have a formula that selects cell c9 and
subtracts it by 1 day. If that day is a Sunday, I want the formula to
subtract by 3 days. However, my current formula doesn't subtract by 3.
Please help

C9 : May 21, 2007

C12 =IF(C9-1= "Sunday",C9-3,C9-1)
 
J

JE McGimpsey

One way:

C12: =C9-1-2*(WEEKDAY(C9)=1)

WORKDAY() is in the Analysis Toolpak Add-in (Tools/Add-ins...)
 
T

T. Valko

=IF(WEEKDAY(C9-1)=7,C9-3,C9-1)

Using that syntax weekday 7 = Saturday

Try:

=IF(WEEKDAY(C9-1)=1,C9-3,C9-1)
=IF(WEEKDAY(C9-1,2)=7,C9-3,C9-1)

Biff
 
J

JE McGimpsey

Probably not a great concern, but if your workbook may be used with
non-English versions of XL, using WEEKDAY(C9)=1 will still work where
TEXT(C9-1,"ddd")="Sun" won't.
 
G

Guest

Hello everyone-

Thanks for your help. All of those formulas work great. I only picked one
and added it to my sheet.
 
T

T. Valko

WORKDAY() is in the Analysis Toolpak Add-in (Tools/Add-ins...)

Yeah, WORKDAY is, but not WEEKDAY.

Think you need to subtract 1 in WEEKDAY:

=C9-1-2*(WEEKDAY(C9-1)=1)

Biff
 
J

JE McGimpsey

Yup, see my two (or is it three) previous posts...

Thanks for the correction.

WORKDAY() is in the Analysis Toolpak Add-in (Tools/Add-ins...)

Yeah, WORKDAY is, but not WEEKDAY.

Think you need to subtract 1 in WEEKDAY:

=C9-1-2*(WEEKDAY(C9-1)=1)

Biff

JE McGimpsey said:
One way:

C12: =C9-1-2*(WEEKDAY(C9)=1)

WORKDAY() is in the Analysis Toolpak Add-in (Tools/Add-ins...)
[/QUOTE]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Formula Needed : Sum on Conditions 3
Hlookup and sum formula 3
Trying to Get a Blank Cell 6
How do I say… 11
Combine rows and Qty 1
Formula HELP!! 1
Adding Date Formula 7
formula help 1

Top