Formula Syntax Not Correct

honkin

Active Member
Joined
Mar 20, 2012
Messages
385
Office Version
  1. 2016
Platform
  1. MacOS
hi

I am trying to have a cell calculate the profit or loss of 2 cells based on a Dutching calculation. Dutching basically just means that if either of the 2 selections has W in row V, the profit is the same regardless of which one has the win. If there is a W in either cell, then the following calculation is carried out:-

Code:
=(((1/T2)/(1/T2+1/T3)*98)*T2)-98

Now this code works fine by itself, but I want to be able to automate the process whereby the result is input based on what is in row V.

So what I need is the following in English; IF V2 or V3 shows L or P, then the result is -100. If V2 or V3 shows W, then perform the calculation above. Here is what I have tried so far, but with no results:-

Code:
=IF(AND(V2={"L","P"}),(V3={"L","P"}),-100,(((1/T2) / (1/T2+1/T3)*98)T2)-98

Code:
=IF(AND(OR(V2={"L","P"}),(V3={"L","P”})),-100,IF(OR(V2=“W”,V3=“W”),(((1/T2) / (1/T2+1/T3)*98)T2)-98

I forgot to add that I want the result only to appear in one of the two rows, as otherwise, the profit would be doubled up if it was in row 2 & 3 and so on.

Any thoughts on how to get this to work correctly?

Thanks in advance
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Perhaps.

=IF(OR(V2="L",V2="P",V3="L",V3="P"),-100,(((1/T2) / (1/T2+1/T3)*98)T2)-98
 
Upvote 0
Perhaps.

=IF(OR(V2="L",V2="P",V3="L",V3="P"),-100,(((1/T2) / (1/T2+1/T3)*98)T2)-98
Cheers Norie

Unfortunately no go on that. Excel suggests a correction to the formula of adding a close bracket after the final 98, but also the result is -100 when V2 is showing W, which should mean it performs the calculation.

Thanks so much for replying
 
Upvote 0
Perhaps 'reverse' things.
=IF(OR(V2="W",V3="W"),(((1/T2) / (1/T2+1/T3)*98)*T2)-98,-100)
 
Upvote 0
Perhaps 'reverse' things.
=IF(OR(V2="W",V3="W"),(((1/T2) / (1/T2+1/T3)*98)*T2)-98,-100)
Hi Norie

Thanks so much, that does the calculation perfectly. I just need to get it to only do the calculation on one of the 2 rows, though, all through the sheet, just calculate each subsequent row. If the formula is copied down, it naturally calculates each row, but each pair of rows are together to make up the calculation, so it needs to act on only one of them

Thanks again
 
Upvote 0
I'm not quite sure I follow.

If you only want to do the calculation for each pair of rows don't copy it down to every row, copy it down every other row.
 
Upvote 0
Hi Norie

OK, you helped me a lot to get to a point whereby all of the calculations work, right up to having up to 5 rows the same; so 1, 2, 3, 4 or 5 rows matching and the individual calculations work.

I now have 5 separate formulas, but I need to put them together and have them work on groups of rows.

Here are the 5 separate formulas:-

For a single row
Code:
=IF(V2="W",98*T2-98,-100)

For 2 rows
Code:
=IF(OR(V16="W",V17="W"),(((1/T16) / (1/T16+1/T17)*98)*T16)-98,-100)

For 3 rows
Code:
=IF(OR(V5="W",V6="W",V7="W"),(((1/T5) / (1/T5+1/T6+1/T7)*98)*T5)-98,-100)

For 4 rows
Code:
=IF(OR(V10="W",V11="W",V12="W”,V13=“W"),(((1/T10) / (1/T10+1/T11+1/T12+1/T13)*98)*T10)-98,-100)

For 5 rows
Code:
=IF(OR(V10="W",V11="W",V12=“W”,V13=“W"),(((1/T10) / (1/T10+1/T11+1/T12+1/T13)*98)*T10)-98,-100)

The groups of rows are determined by a calculation in column E, which is a COUNTIFS comparing columns A + B. So the results in the first 20 rows (E2 - E21) look like this:-

1
1
1
3
3
3
1
1
4
4
4
4
1
1
2
2
2
2
1
1

The rows with 1 in them are individual selections, but those with 2, 3, 4 etc, are all groups of selections where A & B match. What I need is to have any one of the calculations above work only on the corresponding group and only have the single result display, I guess on the last row of the group would be best.

I can construct individual IF(AND(OR statements for 1, and 2 and 3 and 4 and 5. Those should not be an issue, but on copying them down, they will work on every row and of course will lose validity very quickly unless the groups of rows are identified

I mean, even with the group of 4 consecutive 2s towards the bottom of the list, it is actually 2 groups of 2, so how to have a single calculation which would do it all and put the result in the final row of each group?

Does that make sense at all?

Any help gladly accepted
 
Upvote 0
I'm not quite sure I follow.

If you only want to do the calculation for each pair of rows don't copy it down to every row, copy it down every other row.
hi Norie
Simply not possible with maybe 10,000 rows to do. The formula needs to be smart to handle the groups of rows.

cheers
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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