Chris Waller

Board Regular
Joined
Jan 18, 2009
Messages
183
Office Version
  1. 365
Platform
  1. Windows
I have inherited an Excel Spreadsheet (Excel 2002) at work which contains the following formula (it contains 381 characters). The calculations are mostly to do with money. Some of the answers I get are correct. Some are a penny out and others are several pence out. I have managed to work out that where a cell is being divided by the cell at D5 the answer needs to be rounded to two decimal places before being timesed by 7 (this is because I am trying to replicate a process that was previously done manually. TIA


=IF(M5="","",IF(C5>0,IF((E5>M5)*AND(M5>F5),M5-F5,IF((M5>E5)*AND(M5>F5),G5,IF((F5>E5)*AND(E5>M5),0,IF((M5>F5)*AND(F5>E5),E5-F5,IF((F5>M5)*AND(M5>E5),E5-M5,IF(M5="","",0)))))),IF((E5>R5)*AND(R5>F5),M5-((F5/D5)*7),IF((R5>E5)*AND(E5>F5),((E5-F5)/D5)*7,IF((R5>F5)*AND(F5>E5),((E5-F5)/D5)*7,IF((F5>E5)*AND(E5>R5),0,IF((F5>(M5/7)*D5)*AND(M5>(E5/D5)*7),((E5/D5)*7)-M5,IF(M5="","",0))))))))

</SPAN>

TIA
Chris​
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
I got lost trying to follow the logic... but try this: any time you have something like
((E5-F5)/D5)*7
use
ROUND((E5-F5)/D5,2)*7

also, instead of:
IF((E5>M5)*AND(M5>F5),

use:
IF(AND(E5>M5,M5>F5),

or just:
IF((E5>M5)*(M5>F5),
 
Upvote 0
I got lost trying to follow the logic... but try this: any time you have something like
((E5-F5)/D5)*7
use
ROUND((E5-F5)/D5,2)*7

also, instead of:
IF((E5>M5)*AND(M5>F5),

use:
IF(AND(E5>M5,M5>F5),

or just:
IF((E5>M5)*(M5>F5),

Thanks for the help. I have used your round part of the formula plus the If(andE5>M5,M5>F5 option, which appears to have worked. The only problem now is trying to replicate the answers that I have at work from a different system.

It is a bit worrying as most of the figures agree, but there are about 5 that differ by 1 to 5 pence. Perhaps, the other system does not calculate the same way that Excel does.

Thanks once again for your help it is very much appreciated.
 
Upvote 0
In the second part of the formula below, is it possible to roundup all the parts of the formula where it is doing a divide and times? I have tried several variations and all without success. Please see bold type below.


IF((E5>R5)*AND(R5>F5),M5-((F5/D5)*7),IF((R5>E5)*AND(E5>F5),((E5-F5)/D5)*7,IF((R5>F5)*AND(F5>E5),((E5-F5)/D5)*7,IF((F5>E5)*AND(E5>R5),0,IF((F5>(M5/7)*D5)*AND(M5>(E5/D5)*7),((E5/D5)*7)-M5,IF(M5="","",0))))))))
 
Upvote 0
Hello,

Just a suggestion but instead of =ROUND((E5-F5)/D5,2)*7 why not try =ROUND(((E5-F5)/D5)*7,2)? The might help to reduce the difference in pennies.
 
Upvote 0
Thanks for posting your earlier idea. I will give it a go. I have just found out the other system in question has been rounding the figures incorrectly i.e. it has been rounding up in all instances.
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

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