Why does Excel treat '#N/A and #N/A differently? - excel

I am not looking for a specific solution in Excel, just trying to understand a few key difference between certain data types.
Imagine this, I have error code #N/A in cell A1.
I copy and paste this error code in cell A1 as Value (now the red triangle in the top left corner is gone).
I run the following formula in cell B1: =IF(A1="#N/A","Yes","No").
This returns an #N/A error.
But when I change the value in cell A1 to '#N/A, the formula works correctly; it returns Yes in cell B1. If I change the value in Cell A1 to N/A, the formula works correctly as well.
# is being seen by Excel as Text. If for instance I have # in cell A1, and I ask Excel whether this is text using =ISTEXT(A1), Excel returns a True value. If I change the value in cell A1 to #N/A, it is no longer seen as text.
So, my question, why does Excel not treat '#N/A, #N/A, N/A, and # the same?

When the #N/A error code comes up as the result of a formula, Excel is saying "This cell has a not-available type error". When you enter the value of '#N/A into a cell, Excel is saying "This cell has a text/string value of the characters '#N/A". What's happening in each cell is not equivalent to Excel.
You probably want to incorporate the IFERROR or ISNA function into your formula. Right now your code is searching for the later example, the text/string value of '#N/A. You need to use a function that is looking for an error, not a string of text.

Related

If cell has zero entered, display zero. If cell has no value, display nothing [duplicate]

Suppose there is an empty excel sheet. Enter formula "=A1" into the B1 cell. The value of B1 would be 0.
My question is: why the value of B1 becomes zero when referring to an empty cell A1? Any rationales Excel behaves this way?
Thanks.
That is because the formula in B1 returns the value of cell A1.
Excel assigns the value 0 to a blank cell.
To distinguish 0 from blank, in B1 enter:
=IF(A1="","",A1)
FWIW, force a zero-length string with =A1&"". This can also be used to show (an apparently blank) cell when a VLOOKUP of INDEX/MATCH wants to return a zero after encountering a blank cell to return. Two caveats: first, a zero-length string is not truly blank and second, if used with VLOOKUP(...)&"" then any true number that should have been returned as a true number becomes text-that-looks-like-a-number. – Jeeped
Quoting the best answer so I can vote on it :)
I changed my application to =formula&"" according to Jeeped, and works great. Kinda dumb that Index returns Value(formula).

Time showing as 02/01/1900 when clicking on cell

I have a cell that is where the data type is 'custom' and then [h]:mm:ss. The value in the cell is 66:33:00. When clicking on the cell, the formula bar in Excel shows the value as: 02/01/1900 18:30:00.
I am unable to use functions such as SUM or SUMIFS on this cell as the value keeps returning 0:00:00.
What's the reason this?
You should not use 66:33:00 in SUMIFS. Because this value is only for your eyes. The Excel can work with true value only, i.e. 02/01/1900 18:30:00.

Excel Multiple if arguements

My formula:
=IF(ISNA(VLOOKUP(B2,Dists!$D$1:$D$22250,1,FALSE) & AND(B2<>"")),"","MATCHES")
This essentially looks at B2 to see if it returns a VLOOKUP value and if it's blank.
If it's not blank, and VLOOKUP returns a value, then it displays "MATCHES" in the designated cell. If it does not return a value or it is blank, it displays the cell as blank.
I would like to expand on this, but I can't figure it out for the life of me. I am trying to have a cell display blank if B2 is blank, but display "NOT FOUND" if it's not blank and the VLOOKUP returns false. It will display "MATCHES" if the vlookup returns a value.
For example..
B2 is blank so my cell shows as blank.
B2 is not blank and VLOOKUP returns true, so my cell says MATCHES.
B2 is not blank and VLOOKUP returns false, so my cell says NOT FOUND.
Any clue?
Use this:
=IF(B2="","",IF(ISNA(VLOOKUP(B2,Dists!$D$1:$D$22250,1,FALSE)),"NOT FOUND","MATCHES"))
While your code has other structural errors resolved in the answer provided by Scott, your original function =IF(ISNA(VLOOKUP(B2,Dists!$D$1:$D$22250,1,FALSE) & AND(B2<>"")),"","MATCHES") uses the AND() function incorrectly.
AND(), OR(), XOR(), and NOT() in Excel are placed before the different condition. For example, =IF(OR(A1="Foo",A1="Bar"),"Yes","No") returns YES when A1 contains either Foo or Bar.
Microsoft Office Support - AND() function

R1C1 format with negative row reference results in #REF! error in spreadsheet

This formula in VBA:
ActiveCell.FormulaR1C1 = _
"=IF(RC[-6]=""ADD"",CONCATENATE(""QUIET "",RC[-6],"" "",RC[-5],"" "",RC[-4],"" "",RC[-3],"" "",RC[-2]),IF(RC[-6]=""DEL"",CONCATENATE(""QUIET "",RC[-6],"" "",RC[-5],"" "",RC[-4]),IF(OR(**R[-1]C[-6]**=""ADD"",**R[-1]C[-6]**=""DEL""),""//FacultyAG EOJ"","""")))"
Results in this formula in cell:
=IF(RC[-6]="ADD",CONCATENATE("QUIET ",RC[-6]," ",RC[-5]," ",RC[-4]," ",RC[-3]," ",RC[-2]),IF(RC[-6]="DEL",CONCATENATE("QUIET ",RC[-6]," ",RC[-5]," ",RC[-4]),IF(OR(**#REF!**="ADD",**#REF!**="DEL"),"//FacultyAG EOJ","")))
I can manually modify the forumla (relative addressing "on") and it works. But whenever VBA puts the formual in, I get these #REF! errors. It seems to be these -6 row references. (-6 is a valid column ("1").)
The problem occurs because you are inserting the formula into a cell in row 1.
R[-1]C[-6] refers to the cell one row above and 6 cells to the left of the cell in which the formula is placed so, when the formula is placed into row 1, that means it is referring to a cell in row zero, which is invalid. This causes a #REF! error and, even if you move the cell down (by, for instance, inserting a header row above it), the #REF! can't be corrected as Excel no longer knows what it was meant to be saying.
The solution is to ensure that the cell into which you are originally placing your formula is a cell where the formula will actually be valid.

VLOOKUP formula returns '#VALUE!' instead of the text value it should return

I wrote this formula in an Excel cell:
=IF(VLOOKUP(A2, VS!$B2:$B98,1,FALSE ),A2,NA)
What I want to do is, if it finds the A2 value in VS table from B2 to B92 then the function will return and input the value in A2 (in VS table) to my current table. But instead of getting the A2 values, which are text values, I got #VALUE!.
How can I solve it?
Try the following:
=IFERROR(VLOOKUP(A2,VS!$B2:$B98,1,FALSE),"")
What this does is return the value if it finds A2, in the range B2:B98, it doesn't find A2, it returns "" (blank), instead of #VALUE.
Secondly if you're planning on extending this formula, you may want to make the table more 'strictly typed' by adding '$' before the numbers so the range doesn't shift:
=IFERROR(VLOOKUP(A2,VS!$B$2:$B$98,1,FALSE),"")
Lastly, try right click -> Format Cells... and format column A as 'Text' and column B (on sheet VS) as Text as well. Sometimes Excel's Autoformatting features mess with vlookup's results.

Resources