Rounding in a IF AND statement

EmmaTM

Board Regular
Joined
Jan 5, 2022
Messages
86
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have the following if statement:
=IF(AND(AQ19="0",H19=0),"Ok",IF(AND(AQ19="V",H19=0),"Ok",IF(AND(AQ19="1",H19=G19*20%),"Ok",IF(AND(AQ19="S",H19=0),"Ok",IF(AND(C19="Receipt",H19=0),"Ok")))))

IF(AND(AQ19="1",H19=G19*20%) - this bit is resulting in FALSE, I think I need to round this down to 2DP. I think I need to add 'ROUND' into the statement but where?

Many thanks as always
Emma
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
It is very hard to answer this with no idea of what your data looks like. Normally is it risky to compare two real numbers for equality. I am inclined to round both numbers before comparing and do this:

Rich (BB code):
IF(AND(AQ19="1",ROUND(H19,2)=ROUND(G19*20%,2))
 
Upvote 0
Thank you that worked on some of the items where VAT is code 1 = 20% but not all, do you think this could be a case of needing to round up and down? These ones below did not work

1699820623261.png
 
Upvote 0
TypeNetVATGrossVATVat Check
Invoice50,500.640.0050,500.64VOk
Invoice61.470.0061.47VOk
Invoice8,680.500.008,680.50VOk
Receipt-17,030.480.00-17,030.481Ok
Receipt-570,192.900.00-570,192.901Ok
Receipt-16,220.520.00-16,220.521Ok
Invoice60.5012.1072.601Ok
Invoice59.5011.9071.401Ok
Invoice66.0013.2079.201Ok
Invoice33.006.6039.601Ok
Invoice51.5010.3061.801Ok
Invoice356.0071.20427.201Ok
Invoice211.5042.30253.801Ok
Invoice162.0032.40194.401Ok
Receipt-112,415.960.00-112,415.961Ok
Receipt-13,200.000.00-13,200.001Ok
Receipt-104,639.650.00-104,639.65VOk
Invoice2,890.27578.053,468.321Ok
Receipt-6,567.600.00-6,567.601Ok
Receipt-13,559.870.00-13,559.871Ok
Receipt-13,993.570.00-13,993.571Ok
Receipt-3,210.000.00-3,210.001Ok
Receipt-4,094.890.00-4,094.891Ok
Invoice2,195.00439.002,634.001Ok
Invoice100.0020.00120.001Ok
Receipt-1,311.000.00-1,311.001Ok
Receipt-5,697.600.00-5,697.601Ok
Invoice27,331.290.0027,331.290Ok
Invoice469.250.00469.250Ok
Invoice35.190.0035.190Ok
Invoice-2,375.000.00-2,375.00VOk
Invoice11,783.800.0011,783.80VOk
Invoice1,900.000.001,900.00VOk
Receipt-9,397.080.00-9,397.081Ok
Receipt-44,346.470.00-44,346.471Ok
Invoice5,856.000.005,856.00VOk
Invoice5,580.000.005,580.00VOk
Invoice3,248.000.003,248.00VOk
Invoice2,240.000.002,240.00VOk
Invoice160.0032.00192.001Ok
Receipt-192.000.00-192.001Ok
Receipt-1,173.000.00-1,173.00VOk
Receipt-3,250.120.00-3,250.121Ok
Receipt-375,731.040.00-375,731.041Ok
Receipt-54,178.590.00-54,178.591Ok
Receipt-511.130.00-511.131Ok
Receipt-8,370.570.00-8,370.571Ok
Receipt-928.200.00-928.201Ok
Receipt-67,039.270.00-67,039.271Ok
Receipt-22,497.650.00-22,497.65VOk
Invoice304.5060.90365.401Ok
Receipt-365.400.00-365.401Ok
Invoice1,989.250.001,989.25VOk
Invoice1,989.250.001,989.25VOk
Invoice11,130.000.0011,130.00VOk
Invoice372.860.00372.86VOk
Receipt-1,269.500.00-1,269.501Ok
Invoice2,224.41444.882,669.291Ok
Invoice22.244.4526.691Ok
CreditNote-2,887.60-577.52-3,465.121Ok
Invoice5,649.601,129.926,779.521Ok
Invoice2,675.00535.003,210.001Ok
Invoice405.7281.14486.861Ok
Invoice518.00103.60621.601Ok
Invoice1,064.85212.971,277.821Ok
Invoice2,739.63547.933,287.561Ok
Invoice2,332.53466.502,799.031FALSE
Invoice3,960.00792.004,752.001Ok
Invoice1,518.00303.601,821.601Ok
Invoice248.0049.60297.601Ok
Invoice1,267.50253.501,521.001Ok
Invoice440.0088.00528.001Ok
Invoice3,674.80734.964,409.761Ok
Invoice5,686.561,137.316,823.871Ok
Invoice12,005.142,401.0314,406.171Ok
Invoice273.3954.68328.071Ok
Invoice2,280.00456.002,736.001Ok
Invoice1,230.26246.051,476.311Ok
Invoice1,077.20215.441,292.641Ok
Invoice1,077.20215.441,292.641Ok
Invoice1,077.20215.441,292.641Ok
Invoice1,077.20215.441,292.641Ok
Invoice1,077.20215.441,292.641Ok
Invoice2,851.20570.243,421.441Ok
Invoice2,441.800.002,441.80VOk
Invoice28,939.600.0028,939.60VOk
Invoice1,600.20320.041,920.241Ok
Invoice4,536.95907.395,444.341Ok
Invoice8,576.701,715.3410,292.041Ok
Invoice1,864.50372.902,237.401Ok
Invoice4,039.75807.954,847.701Ok
Invoice20,631.740.0020,631.74VOk
Invoice23,342.500.0023,342.50VOk
Invoice1,998.000.001,998.00VOk
Invoice59,430.000.0059,430.00VOk
Invoice1,907.50381.502,289.001Ok
Invoice368.7173.74442.451Ok
Invoice1,493.76298.751,792.511Ok
Invoice1,209.10241.821,450.921Ok
Invoice9,194.111,838.8211,032.931Ok
Invoice1,071.00214.201,285.201Ok
Invoice2,493.49498.702,992.191Ok
Invoice2,268.00453.602,721.601Ok
Invoice2,750.00550.003,300.001Ok
Invoice1,848.00369.602,217.601Ok
Invoice3,250.00650.003,900.001Ok
Invoice5,808.401,161.686,970.081Ok
Invoice2,730.60546.123,276.721Ok
Invoice430.4986.10516.591Ok
Invoice1,288.00257.601,545.601Ok
Invoice4,257.00851.405,108.401Ok
Invoice108,088.3921,617.63129,706.021FALSE
Invoice257,552.0051,510.39309,062.391FALSE
Invoice1,743.96348.852,092.811FALSE
Invoice23.994.8028.791Ok
Invoice74,802.1614,960.4589,762.611FALSE
Invoice84,932.4116,986.50101,918.911FALSE
Invoice2,675.09534.983,210.071FALSE
Invoice13,965.002,793.0016,758.001Ok
Invoice1,650.00330.001,980.001Ok
Invoice6,864.001,372.808,236.801Ok
Invoice6,500.001,300.007,800.001Ok
Invoice16,576.493,315.3019,891.791Ok
 
Upvote 0
First, I am assuming the 0 and 1 data in column AQ is numeric. If so, do not put quotes around 0 and 1 in the formula.

I'm not seeing a problem. Here is your data with the formula I recommended. Here are the rows where VAT Check comes back FALSE, and it should be FALSE as far as I can tell. I added the last three columns as a check.

$scratch.xlsm
CGHIAQARASATAU
1TypeNetVATGrossVATVAT CheckCalculated VATActual VATMatch
2Invoice2332.53466.52799.031FALSE466.51466.50FALSE
3Invoice108088.3921617.63129706.021FALSE21617.6821617.63FALSE
4Invoice25755251510.39309062.391FALSE51510.4051510.39FALSE
5Invoice1743.96348.852092.811FALSE348.79348.85FALSE
6Invoice74802.1614960.4589762.611FALSE14960.4314960.45FALSE
7Invoice84932.4116986.5101918.911FALSE16986.4816986.50FALSE
8Invoice2675.09534.983210.071FALSE535.02534.98FALSE
VAT (2)
Cell Formulas
RangeFormula
AR2:AR8AR2=IF(AND(AQ2=0,H2=0),"Ok",IF(AND(AQ2="V",H2=0),"Ok",IF(AND(AQ2=1,ROUND(H2,2)=ROUND(G2*20%,2)),"Ok",IF(AND(AQ2="S",H2=0),"Ok",IF(AND(C2="Receipt",H2=0),"Ok")))))
AS2:AS8AS2=IF(OR(AQ2<>1,C2="Receipt"),"",ROUND(G2*20%,2))
AT2:AT8AT2=IF(OR(AQ2<>1,C2="Receipt"),"",ROUND(H2,2))
AU2:AU8AU2=AND(AQ2=1,ROUND(H2,2)=ROUND(G2*20%,2))
 
Upvote 0

Forum statistics

Threads
1,216,111
Messages
6,128,899
Members
449,477
Latest member
panjongshing

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