Multiple IF and AND statement

Woofy_McWoof_Woof

Board Regular
Joined
Oct 7, 2016
Messages
60
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm attempting to create an IF statement that will depend on three potential outcomes and to also split the outcomes into two columns. For instance in the attached picture in row 3 there is a positive position on day one of 5, on day 2 this changes to positive 10, a change of positive 5. Therefore, the change of positive 5 will appear on the statement and 0 will appear on the invoice. The same logic applies to to row 4 even though the position on day 2 is less than day one (but as the position on day 2 is still above zero) so it appears on the statement.

However, in row 5 the position on day one is positive 5 though the position on day 2 is negative 10, a change of negative 15. I need negative 5 to appear on the statement and negative 10 to appear on the invoice.

This logic should apply to all rows and split the volume out accordingly, I have tried to do a few different combinations on IF and AND statements and I can get the logic to work when its either all on the invoice or all on the statement but can't seem to get it to work when the volume should be split across both the statement and invoice.

Any help would be greatly appreciated.

Cheers
Logic.PNG
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Is this what you need?
Book1
BCDEFGHI
3510550
452-3-30
55-10-15-5-10
6-1015251510
7-10-15-50-5
8-10-5505
Sheet4
Cell Formulas
RangeFormula
H3:H8H3=IF(AND(B3>0,D3>0),F3,IF(AND(B3<0,D3<0),0,MAX(B3+D3,D3)))
I3:I8I3=F3-H3
F3:F8F3=0-B3+D3
 
Upvote 0
Here is my effort.
Not sure if this is a universal solution.
I can only assume logic that appears to solve for the given data.

Book1
BCDEFGH
1Day1Day1Day2Day2ChangeStatementInvoice
25Positive10PositiveStatement50
35Positive2PositiveStatement-30
45Positive-10NegativeBoth-5-10
5-10Negative15PositiveBoth1510
6-10Negative-15NegativeInvoice0-5
7-10Negative-5NegativeInvoice05
Sheet1
Cell Formulas
RangeFormula
G2:G7G2=IF(SIGN(B2)<>SIGN(D2),SIGN(D2)*MAX(B2,D2),IF(SIGN(D2)=1,D2-B2,0))
H2:H7H2=D2-B2-O2

Hope that helps.
 
Upvote 0
Sorry.... there was a retained reference in the H formula, above, to a redundant trial column.

My solution should be......

Book1
BCDEFGH
1Day1Day1Day2Day2ChangeStatementInvoice
25Positive10PositiveStatement50
35Positive2PositiveStatement-30
45Positive-10NegativeBoth-5-10
5-10Negative15PositiveBoth1510
6-10Negative-15NegativeInvoice0-5
7-10Negative-5NegativeInvoice05
Sheet1
Cell Formulas
RangeFormula
G2:G7G2=IF(SIGN(B2)<>SIGN(D2),SIGN(D2)*MAX(B2,D2),IF(SIGN(D2)=1,D2-B2,0))
H2:H7H2=D2-B2-G2
 
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,172
Members
448,870
Latest member
max_pedreira

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