VLookup not returning the results - excel

I'm not sure why my VLOOKUP formula is not working like the screenshot below. The value is right there as highlighted. I want to output the value in Column G, but changing the 3rd parameter to 1 or 2 doesn't work.
Help is appreciated. Thanks much in advance.
Formula: =VLOOKUP(B2,$F$1:$G$421,2,FALSE)

One thing you may want to look at.
I notice your data is left justified and that's normally the case for textual rather than numeric fields - it's possible to left justify numerics but it's neither the default nor the general practice.
If they are textual, there's a chance one or more of them may have leading or trailing spaces. That would prevent the lookup from finding a match.
Select (in turn) B2 and F1 and use the arrow keys in the formula box to check this is not the case.
In cases like this, I tend to (temporarily) set B2 to the formula =F1 just to see if it can find a match that's guaranteed (then use CTRL-Z to revert).
If that change results in the lookup working then obviously the (original) B2 and F1 are not the same value, and you need to work out why (hidden spaces, wrong types, and so on).

It looks like you are comparing text to number (see the green triangle in your value cell). You have to convert the value in your source cell or matching cells to same type. To convert source to number use excel function such as int or value. Hope this helps.

Another way to convert text to number format is to multiply by 1 and then replace original text values with these new number values...

If you are doing lookup where you have a mix of text and numbers (i.e. looking up a text version of a number in a list of real numbers) you can also make use of the VALUE function... this will convert numbers stored as text to real numbers.
Embed it like so:
=VLOOKUP(VALUE(B2),$F$1:$G$421,1,FALSE)
If you have a mix of text numbers and text text to look up in numbers/text then you can do:
=VLOOKUP(IFERROR(VALUE(B2),B2),$F$1:$G$421,1,FALSE)
to change numbers stored as text to numbers, but leave other text as is...

Related

Excel color scale based on alphabetical order

I like Excel's color scale feature in the Conditional Formatting menu and I am trying to get it to work for text values.
The way it works for numerical values is that it color-codes the lowest and highest values each with a certain color and then any values in between form a gradient between the min and max colors.
I'd like to be able to do this with text based on the alphabetical order. So let's say I have a table of:
AT ANY BOY CAT
BAT CAT DAD AT
"ANY" would be the lowest value and "DAD" is the highest. I've applied the color scale to the table but none of the cells get colored. It seems like the values need to be numerical for a color scale to work. Is there a way to make this work? I'd rather not dive into any VB macros.
Using Excel 2010
JNevill's answer applies to a single letter but the same CODE function can be used multiple times with functions like MID or RIGHT to get unique numbers for each text value.
For example, if two text values are "Apple" and "Allure" in cells A3 and B3 you could use the following formulas:
=CODE(a3)
will get you 65
=CODE(b3)
will also get you 65 since you're asking for the ASCII of letter A both times so this won't work
=CODE(mid(a3,2,1))
will get you 112 since you're asking for the ASCII of the second letter ("P")
=CODE(mid(b3,2,1))
will get you 108 since you're asking for the ASCII of the second letter ("L") so this would work
You can concatenate the values of the first and second letters to get a longer, unique value:
=CODE(a3) & CODE(MID(a3,2,1))
will get you 65112
=CODE(b3) & CODE(MID(b3,2,1))
will get you 65108
Use however many combinations of the MID and RIGHT functions with CODE to get unique values that you can then apply color scales to.
NOTE: You'll have to convert any concatenated string into a number, so you can wrap the whole formula in =VALUE( xxxx ) and use the colour scales on that.
Be thoughtful of how complex the combinations need to be based on your text data set, because in the example of Apple and Allure, a combination of the first letters and last letters (you can get the last letters using the RIGHT function) would both be looking at A's and E's and therefore return the same number.
It's a bit of a workaround and not exactly what you are looking for, but in the next column (or row) you could use =Code(A1)... =Code(A2)... etc
This will get the ASCII character number for the character in each cell, which is a number. Then you could apply your conditional formatting to that.

Excel: Omit minus sign when formatting cell

First of all, I realize that there are threads like this already, but I cannot get the examples I've seen to work. What I want to accomplish is that a cell value should be presented as "x,xx" and in red color if the value is higher than 0, and otherwise in Color 14.
For instance, if this formatting would be used on
0,05-0,03
It would return (in red):
0,02
What I have done is to format the cell as:
[Red][>0]0,##;[Color14][<=0]0,##;
but it prints out a minus sign for values less than or equal to 0, which I do not want. Changing to:
[Red][>0]0,##;[Color14][<=0]0.##;
Omits the minus sign, as I want, but it makes the cell red which is not intended.
I've also tried a numerous combinations of ",", "." and "#" but it just wont work as intended.
I hope anyone can shed some light into this.
EDIT Using "General" instead of "0,##" prints out many more decimals than desired.
EDIT2 I use a Swedish Excel and hence I translate the formulas to Swedish formulae. Perhaps of importance?
See: https://support.office.com/en-us/article/Create-or-delete-a-custom-number-format-78f2a361-936b-4c03-8772-09fab54be7f4
A number format can have up to four sections of code, separated by semicolons. These code sections define the format for positive numbers, negative numbers, zero values, and text, in that order.
<POSITIVE>;<NEGATIVE>;<ZERO>;<TEXT>
So for your requirement no [conditions] are needed.
[Red]0,##;[Color14]0,##;[Color14]0,##
will suffice.
As for your further descriptions
[Red]0,00;[Color14]0,00;[Color14]0,00
may be better.
You cannot change the value of the cell with formatting, only the appearance.
So if you want the cell value to actually be positive it is not possible to do this way.
If this is what you actually want to do, try =ABS(A1) (will have to be done in another cell)

How to add cells with mix of 6 to 8 decimal places together

Because of floating point values, I cannot add a string of cells that contain values such as:
0.08178502
0.09262585
0.13261762
0.13016377
0.12302067
0.1136332
0.12176183
0.11430552
0.09971409
0.125285
Even if I try adding the first two through a sum formula or auto sum through selecting them, excel spits out an error. I have googled this like crazy and tried to change number formats. Is there a function that can allow me to add this information ?
Screenshot:
The spreadsheet is available on my Dropbox.
Those numbers are all preceded by a NBSP (Char Code 160). So, in order to sum them, you have to remove that. Many solutions. Here's one:
=SUMPRODUCT(--SUBSTITUTE(A1:A18,CHAR(160),""))
If a formula like:
=A1+A2+A3+A4+A5+A6+A7+A8+A9+A10
produces:
#VALUE!
then your "numbers" cells contain non-visible characters.
They must be removed before the formula will work.
If the cells contain text strings and not actual values you will need to convert the text to numeric values before performing any calculations. The function "=value(cell)" will bring the numeric value.
e.g.: A1 contains "000.12345678" (or some other non-numeric presentation of numerals)
In cell B1 type: =value(a1)
Cell B1 now operates as the real number 0.12345678
Oddly enough, the fact that it said 0.xxxxx in all numbers vs. .xxxxx is what the issue was. I'm just sharing that for folks who google/search and have same issue.
All I had to do was select that whole row and do a search in replace for "0." and make it just "." and now my numbers were usable in equations. For some reason the adjustment of formating as many searches suggested wasn't working

Why does Excel MATCH() not find a match?

I have a table with some numbers stored as text (UPC codes, so I don't want to lose leading zeros). COUNTIF() recognizes matches just fine, but MATCH() doesn't work. Is there a reason why MATCH() can't handle numbers stored as text, or is this just a limitation I'll have to work around?
Functions like MATCH, VLOOKUP and HLOOKUP need to match data type (number or text) whereas COUNTIF/SUMIF make no distinction. Are you using MATCH to find the position or just to establish whether the value exists in your data?
If you have a numeric lookup value you can convert to text in the formula by using &"", e.g.
=MATCH(A1&"",B:B,0)
....or if it's a text lookup value which needs to match with numbers
=MATCH(A1+0,B:B,0)
If you are looking for the word test for example in cell A2, type the following:
=MATCH(""&"test"&"",A2,0)
If this isn't working then try =Trim and =Clean to purify your column.
If =Trim and =Clean don't help, then just use the left 250 characters...
(As the Match Formula may encounter a timeout/overflow after 250 characters.)
=Left(A2, 250)
If you are using names to refer to the ranges, once you have fixed the datatypes also redefine any names which refer to those ranges.

Storing numbers are text Excel 2007

When numbers are stored as text in Excel you see this little guy http://imgur.com/zXdwD
in the upper-left hand corner. when you click on it it gives you the option of converting the text representation of a number to a number upon which math can be done. also, when stored as text numbers appear on the left side of the cell opposed to the right one. I have an array of numbers which are stored as text, but they don't offer that little green thing to convert them to numbers. It may sound trivial but I'm using the Vlookup function to reference a large column of numbers to a code name, but it's not being recognized. And the only thing I can think of is that it's somehow being read differently (the codes are most defintely in the lookup table, and ctrl+f will find them). I want to know if anyone has an idea about what's happening.
Thanks.
The smart tag is a little finicky at times. There's a couple of things you can do.
If you're using code, you can multiply the cells in the range by 1, this will convert them to a number.
Alternatively you can convert the number you're matching to a string and then vlookup. Something similar to:
=VLOOKUP(TEXT(A1,"#"),B1:D10,2,false)
Note TEXT(A1,"#") would round to no decimal places, you may have to adjust the formatting.
The format of some of the cells in the lookup table maybe formatted as text. If there are a lot of them you can create a macro that corrects them. I had the same issue in this SO question although it was the opposite problem.
Another way to correct them would be to copy all the cells in the lookup table in that column and in an adjacent blank column edit>paste special>values>add which makes each of them numeric. Then copy them and paste those back over the originating cells.
A quick trick to convert all numbers formatted as text back to umber format is to copy the data into the "Notepad" application. Then select and copy the data from "Notepad back into your spread sheet and everything will be converted to number format.

Resources