I have 2 tables:
tblCodes contains 2 columns:
Code (4-char code can be text or numeric), Code Name (text description)
tblSerialNum contains 3 columns:
SerialNum column (can be text or numeric),
Code column is 1st 4 chars of SerialNum using LEFT() function,
Code Name column uses index/match to look up Code Name that matches Code:
=INDEX(tblCodes[Code Name],MATCH([#Code],tblCodes[Code],0))
sample tables
The problem is with the serial # 1234001: the MATCH doesn't work when the Code is all numeric because the LEFT() function always returns a string "1234" and it doesn't find it in the code table because it reads as number 1234.
I can't convert the values in the tlbSerialNum[Code] column to numeric because some are text "x333".
I've tried formatting the tblCodes[Code] column to text, but the function still treats 1234 as numeric.
I can type '1234 into tblCodes[Code] using an apostrophe to force it as a text, but I don't want to rely on my users to always remember to enter it that way.
Any suggestions?
Change everything to text in the formula:
=INDEX(tblCodes[Code Name],MATCH([#Code]&"",tblCodes[Code]&"",0))
This is now an array formula and depending on one's version may need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
Related
unfortunately i can't find the solution to the following problem.
I have a table (DATA) consisting of a column A with non-unique identifiers and a column B with several 4-digit codes separated by a space.
In another table (CODES) i have a column A for unique identifiers that are occuring in column A (DATA) and a column B with several, by comma delimited 4-digit codes.
My goal is to check all entries in the first table (DATA) and list those NOK that have at least one code in column B identified in the other table (CODES)
I've used the following formula:
=IFERROR(IF(ISNUMBER(SEARCH(INDEX(CODES, MATCH([#A], CODES[A], 0), MATCH("B", CODES[#Kopfzeilen],0)),[#B])), "NOK", "OK"), "OK")
Unfortunately that only searches for the complete string in colum B (CODES) and not for every value delimited by a comma.
Is it possible to have a formula without using VBA (as this creates problems on sharepoint, where the file is being stored)?
Use FILTERXML:
=IF(OR(ISNUMBER(SEARCH(FILTERXML("<a><b>"&substitute(INDEX(CODES, MATCH([#A], CODES[A], 0), MATCH("B", CODES[#Headers],0)),",","</b><b>")&"</b></a>","//b"),[#B]))), "NOK", "OK")
Make sure you change #Headers to your language if different than English
This will need to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode in Excel 2013.
I'm wondering if there's a shortcut to the following.
I have a product form that customers will fill out and I need the formula to format the part numbers they enter correctly. If it doesn't their entry doesn't match the products list.
Below are the variety of text/number/other variations...
Excel Columns/ Rows Example
101
7-2009
7-5601-RT
G-2121
5728B
PI-PIXES
I got all but the last one working with this formula:
FORMULA1
=AND(SUMPRODUCT(--ISNUMBER(--MID(B40,ROW($1:$9996),1)))<LEN(B40),MIN(FIND({0,1,2,3,4,5,6,7,8,9},B40&"0123456789"))<=LEN(B40))
I also have to keep it in .xls format.
Basically, I have one column that checks this above and it returns TRUE/FALSE.
I have another formula that checks for text:
FORMULA2:
=IF(I40=FALSE,"NUMBER", "TEXT")
The final column TESTS FOR TEXT/NUMBER.
FORMULA3:
=IF(J40 = "NUMBER", VALUE(B40), B40)
PI-PIXES is flagged as number because of the dash(hyphen).
Without any other option, I'm considering adding a third column to find TEXT with hyphens. I would then change FORMULA3 check if both if column 1 = TRUE+column 2 = TRUE and column 3 = TEXT but this is getting complicated and I'm wondering if there's a shortcut.
I think this does it:
=IF(SUBSTITUTE(B40,"-","")<>TEXT(B40,"#"),B40,IFERROR(VALUE(B40),B40))
If there are hyphens, it returns the B40 unchanged, eliminating dates. Otherwise, it handles it as a normal Value conversion with IFERROR.
This should work for older versions of Excel:
=IF(SUBSTITUTE(B40,"-","")<>TEXT(B40,"#"),B40,IF(ISERR(VALUE(B40)),B40,VALUE(B40)))
Or even this:
=IF(ISERR(FIND("-",B40)),IF(ISERR(VALUE(B40)),B40,VALUE(B40)),B40)
enter image description hereI am trying to write a formula that will allow me to return a value based on it being matched with a short text string that is contained in a longer text string. Please see below. I would like the "Unit Time" column in the second table to retrieve that corresponding value from the first table by matching the shorter text string in the product column of the first table in the longer product name in the second table. Any thoughts would be appreciated.
Thanks
excel
If the product will always be XX-XX then you can use:
=INDEX(B:B,MATCH(Left(D2,5),A:A,0))
If the product can be more than 2 characters around the dash, then you'll have to use the Find() formula to get the position of the end of the product in col D instead of Left().
To account for row 4 as Scott pointed out:
=INDEX(B:B,MATCH(LEFT(D2,FIND("-",D2,4)-1),A:A,0))
This will find the second dash in the string and use the variable length for the Left() function.
I have variating numeric entries (SF123456, SF142365, ...). Every number of the numeric entries corresponds to a specific code. For each number of each entry I need to enter on a separate cell the corresponding code (download here example sheet: www.nivpat.com/Example.zip) How can I create an automatic function as I have thousands of entries to divide into codes... thanks!
Alright. What I did to solve this one is this:
Remove the '=' sign in your match table to be able to do a VLOOKUP on it;
Add the position of the digit you want to look up in the row 9 right above the headings. You might want to hide this row for cleaner presentation;
I used the following formula in the cells to extract the values:
=VLOOKUP(VALUE(MID($A11, B$9, 1)), $A$2:$B$7, 2, 0)
The VLOOKUP does the lookup on your table in A2:B7. The MID() extract exactly one character beginning with the character specified in B9 (in this case it would be 3). And the VALUE() converts the text string to a number to be able to do a match with the table above.
The only thing you now have to do is to drag your formulas and it's working !
I have an Excel formula reading data from a column. The data in that column is sometimes a date-like format, such as "10-11". Despite the fact that I've ensured that column is text formatted -- and all values display correctly as plain text, not reinterpreted as dates -- the formula is basically reinterpreting them as dates in the reference.
I need a way to force the formula's cell reference to interpret the cell as text. I tried TEXT(A1, "#") but it doesn't work -- it gives the numeric value of the date.
Brian Camire's answer explains why, but here's a worksheet function that will work for you. Note that you have to create that numeric array in it based on how long the longest string will be. It's an array formula, so when you first enter it you have to hit CTRL-SHIFT-ENTER, then you can click and drag it down the column.
=LEFT(A1, MATCH(FALSE, ISNUMBER(VALUE(MID(A1, {1,2,3,4,5}, 1))),0) - 1)
Short answer: When referring to number-like (or date-like) text values in a formula, don't use them in a place in the formula where Excel is expecting a number.
Long answer: Even if the source column is formatted as text and the values in the source column are truly entered as text (and not numbers, including dates), Excel may automatically convert text values to numbers (including dates) when you reference them in a formula if you use them in a place where Excel is expecting a number (or date).
For example (assuming US date formats), in a blank worksheet:
Set the format for column A to Text.
In cell A1, enter the value 10-11.
In cell B1, enter the formula =T(A1). The T() worksheet function returns the supplied value if it is text. Otherwise, it returns an empty string. The result of the formula in cell B1 should be 10-11, indicating that the value of A1 is text, not a number or date (in which case the result would be an empty string).
In cell C1, enter the formula =A1.
In cell D1, enter the formula =T(C1). The result should also be 10-11, indicating that the value of the formula in C1 is text, not a number or date. This shows that you can (sometimes) use a text value that looks like a number (or date) in a formula and have Excel treat it as text (which is what you want).
In cell E1, enter the formula =A1+0. The result will be 40827. This is the numeric value of the date October 11, 2011. This shows that you can (sometimes) use a text value that looks like a number (or date) in a formula and Excel will automatically convert it to a number (which is what you observed) if you use it in a place (like on either side of the + operator) where Excel is expecting a number.
To insert a value into a cell and have it not be auto-formatted, and just treated as text, you can enter it like this:
=("cell data")
eg:
=("+1 3456789")
When you use &"", Excel converts the results of a formula to text (like *1 would convert to numbers).
Thus, you can use this formula:
=TEXT(A1;"jj-mm")&""
If you put a single quote in front of the text in the cell, it should be represented as text on all references:
'10-11
Just add zero to the input!
I was having a similar problem where I had a list of numbers with a text prefix (like FOO-1, FOO-25, FOO-979) but I just wanted the number part (1, 25, 979) so I could run another formula off of that. I was using SUBSTITUTE to replace the text portion with blank, but my other formula using these numbers was coming up with bogus results. I ended up making my formula like this:
=SUBSTITUTE(B1:B10,"FOO-","")+0, and now the ISNUMBER is saying TRUE where before it was saying FALSE.
In my case, I have a form worksheet that is used by dealers to ad parts and have it calculate the final cost; it references a locked "products" sheet. The problem is that I had no way of controlling what they entered.
Products can be like:
101 = A true number
7-2009 = Reads as date
7-5601-RT = TEXT/NUMBER reads as both number or text (NOT SOLVED YET)
CP6072CD = reads as plain text
I have most of this figured out; the only one that isn't is the one that reads as both text/Number.
In case anyone is looking for a similar solution, i did the following:
I created three additional columns to test and display the three different cases: "NUMBER", "DATE" , "TEXT".
DATE: =NOT(ISERROR(DATEVALUE(B42)))
ISOTHER: =(ISNUMBER(--(MID(B42,ROW(INDIRECT("1:"&LEN(B42))),1))))
NUMBER: =ISNUMBER(B42)
NUMBER/TEXT: =NOT SOLVED YET
I42 = DATE
J42 = NUMBER
K42 = OTHER
L42 = TEXT
M42 = THE RESULT OF THE QUERY BELOW
=IF(AND(I42 = FALSE, J42 = FALSE, K42 = TRUE), "NUMBER", IF(AND( I42 = TRUE, J42= FALSE, K42=TRUE), "DATE", "TEXT"))
This (ABOVE) tests all the true/false results and depending on what the value turns out to be, I format each of them using:
ISNUMBER = VALUE(B42)
DATE FORMATTED AS B42*1
ELSE TEXT - AS ORIGINAL
=IF(M42 = "NUMBER", VALUE(B42), IF(M42 = "DATE", B42*1, B42))
So now I just need to figure out how to test if something is both text and number because the 7-5601-RT tests out as the same as number: "FALSE, FALSE, TRUE, TRUE"