How to compare two cells when one has a #VALUE! error?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,759
Office Version
  1. 365
Platform
  1. Windows
I'm working on a UDF to convert Moneyline odds into percentages. I created a 2-column table with a bunch of Moneyline odds in Column 1 and manually entered the correct percentages in Column 2. I added Column 3 that calls my UDF to generate the correct percentages based on the values in Column 1. I added Column 4 to compare Columns 2 & 3 to ensure that the UDF is working.

My problem is that the UDF also checks for invalid Moneyline odds and returns a #VALUE! error. I put the text string “#VALUE!” in Column 2, but the compare expression returns a value error not true or false. This is the compare expression I'm using. Is there one that will work?

VBA Code:
=Table1[@[UDF]]=Table1[@[Manual]]

And here's an except of the table.

1741928236298.png
 
You could try something like:

Excel Formula:
=IF(ISERROR(Table1[@[UDF]]),IF(ISERROR(Table1[@[Manual]]),ERROR.TYPE(Table1[@[UDF]])=ERROR.TYPE(Table1[@[Manual]]),FALSE),Table1[@[UDF]]=Table1[@[Manual]])

If you just want to check for errors, then enter Error instead of #VALUE! and you could use:

Excel Formula:
=IFERROR(Table1[@[UDF]],"Error")=Table1[@[Manual]]
 
Upvote 0
Solution
This might work for you:
Excel Formula:
=COUNTIFS(Table1[@[Manual]:[UDF]],[@Manual])=2

Book1
ABCD
5MoneylineManualUDFEqual?
610050%50%TRUE
7-10075%50%FALSE
8#N/A#N/ATRUE
9#VALUE!#VALUE!TRUE
Sheet1
Cell Formulas
RangeFormula
D6:D9D6=COUNTIFS(Table1[@[Manual]:[UDF]],[@Manual])=2
 
Last edited:
Upvote 0
You could try something like:

Excel Formula:
=IF(ISERROR(Table1[@[UDF]]),IF(ISERROR(Table1[@[Manual]]),ERROR.TYPE(Table1[@[UDF]])=ERROR.TYPE(Table1[@[Manual]]),FALSE),Table1[@[UDF]]=Table1[@[Manual]])

If you just want to check for errors, then enter Error instead of #VALUE! and you could use:

=IFERROR(Table1[@[UDF]],"Error")=Table1[@[Manual]][/code]
Your suggestion gave me an idea which seems to work.

2025 Warriors Odds.xlsm
CDEFG
5MoneylineManualUDFEqual?Equal ?
6+10050.0000%50.0000%TRUETRUE
7-10050.0000%50.0000%TRUETRUE
8+50016.6667%16.6667%TRUETRUE
9-50083.3333%83.3333%TRUETRUE
10+10009.0909%9.0909%TRUETRUE
11-100090.9091%90.9091%TRUETRUE
120100.0000%100.0000%TRUETRUE
13#VALUE!#VALUE!#VALUE!TRUE
MrExcel Equal
Cell Formulas
RangeFormula
E6:E13E6=CvtOdds([@Moneyline],"M","%")
F6:F13F6=[@UDF]=[@Manual]
G6:G13G6=IFERROR([@UDF]=[@Manual],TRUE)
 
Upvote 0
Your final solution in column G, doesn't work. If one column gives an error and the other doesn't it will return True when you really want False.
The issue is that almost all functions in Excel will error out when they see an error. The only exception that I have found that actually recognises the error as a value in its own right is the CountIf(s), SumIf(s) family of function.

In those functions you can put =COUNTIFS(Table1[@[Manual]:[UDF]],#VALUE!)
and it will count the #VALUE!'s.
Every other function I have seen will just return an error.

In your requirement you want Manual to equal UDF, so if you take the value in either column and use that as the count criteria if both have that value the count will be 2. (Since you are using a value from one of the 2 columns being counted it will always be either a count of 1 or 2.
My suggested formula is:
=COUNTIFS(Table1[@[Manual]:[UDF]],[@Manual])=2
The long form of that would be:
=IF(COUNTIFS(Table1[@[Manual]:[UDF]],[@Manual])=2, TRUE, FALSE)

20250314 Recognising Errors VALUE NA etc using CountIfs JenniferMurphy.xlsx
ABCDEF
3MoneylineManualUDFJenniferRory 1Alex
410050%50%TRUETRUETRUE
5-10075%50%FALSEFALSEFALSE
650%#VALUE!TRUEFALSEFALSE
7#VALUE!50%TRUE#VALUE!FALSE
8#N/A#VALUE!TRUEFALSEFALSE
9#N/A#N/ATRUETRUETRUE
10#VALUE!#VALUE!TRUETRUETRUE
Data
Cell Formulas
RangeFormula
D4:D10D4=IFERROR([@UDF]=[@Manual],TRUE)
E4:E10E4=IF(ISERROR([@UDF]),IF(ISERROR([@Manual]),ERROR.TYPE([@UDF])=ERROR.TYPE([@Manual]),FALSE),[@UDF]=[@Manual])
F4:F10F4=COUNTIFS(Table1[@[Manual]:[UDF]],[@Manual])=2
 
Upvote 0
Your final solution in column G, doesn't work. If one column gives an error and the other doesn't it will return True when you really want False.

You're probably right. It was just a quick and dirty solution on my part. This is all kind of a quick and dirty project. All I really care about is that the numerical values are equal. Both columns do that. I can assess the cases where the function returns an error visually.

I'm sure your solution works. All of your solutions over the years have worked. I just don't understand it based on a quick look and I don't have time right now to dig into it in more detail. If I need to in the future, I know where I can come back to try and figure it out.

In the meantime thanks for the time and effort that you always put into every reply. Perhaps this solution will be of use to others. Thank you
 
Upvote 0

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