Searching a cell with a string of comma delimited values in Excel - excel

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.

Related

Using Excel index/match to search a column containing numbers and text

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.

Determine sequence of most used words in Excel data set

I need to determine sequence of most occurring word in a excel data set. Eg.
A B C D
Joyce Bremner Lewis Chapman Claire Harper
Lesley Brown Brian Clough Natalie Hassan
Emma Cartwright Janet Coldwell Gillian Hedley
Lewis Chapman Sheena Doig Lesley Brown
Brian Clough Karen German Emma Cartwright
Janet Coldwell James Gledhill Lewis Chapman
Sheena Doig Maggie Gowan Brian Clough
Which name is the most occurring and then 2nd most occurring word and so on.
I have found solution for determining the most concurring word in sequence when you take only one column into consideration but struggling to combine for multiple column. Below is the formula used:
Enter this array formula in C2:
=IFERROR(INDEX(A2:A10,MODE(MATCH(A2:A10,A2:A10,0)+{0,0})),"")
Enter this array formula in C3 and copy down until you get blanks:
=IFERROR(INDEX(A$2:A$10,MODE(IF(COUNTIF(C$2:C2,A$2:A$10)=0,MATCH(A$2:A$10,A$2:A$10,0)+{0,0}))),"")
Just in case the single column and pivot are a feasible idea...
Put all the names in one column
Format as table (my pref.)
Select "Summarize as pivot table"
Add "Name" field to Rows and Values

Return Dates of Three Consecutive Values in a Row

I have a data file and I need to return the dates of when the value (MaxT) is greater than or equal to 30 (>=30) for 3 consecutive days.
Data File:
Date, MaxT
1872-03-01,31
1872-03-02,29
1872-03-03,37
1872-03-04,40
1872-03-05,22
1872-03-06,9
1872-03-07,28
1872-03-08,31
1872-03-09,35
1872-03-10,37
1872-03-11,44
1872-03-12,29
1872-03-13,35
1872-03-14,48
1872-03-15,33
1872-03-16,31
1872-03-17,38
1872-03-18,31
1872-03-19,42
1872-03-20,20
1872-03-21,24
1872-03-22,31
I have attempted to figure this out using the following code but, I do not think I'm even in the ballpark...
Attempted Code:
=SUMPRODUCT(--(FREQUENCY(IF(B2:B23>=30,ROW(B2:B23)),IF(B2:B23>=30,ROW(B2:B23)))=3))
I'm assuming that your data file consists of 2 columns Date and Max T. If they are delimited by commas, you need to split them to 2 different columns using Text to columns delimited by commas ,.
The Date should be in Column A and Max T in Column B.
Enter the below formula in cellC2 and drag down,
=IF(AND(B2>=30,B3>=30,B4>=30),"Consecutive Range","")
The starting of the consecutive range of values greater than 30 will be shown in the output as above. You could then use a filter of some other excel function like Index-Match to get the corresponding dates. Hope this helps.
Alright, I got it to work, but I'm not entirely sure how you would make it work without separating the formula into multiple cells.
One potential solution would be to write some of the formulas into a sheet that's in the background, place the final part of the formula in the front sheet and have it reference the "hidden" bits of the formula.
First, I wrote the data in columns... "Date" in Column A, "MaxT" in Column B.
The first part of the formula is written in cell D2:
=IF(B2>=30,B2,"")
The next part of the formula is written in cell E2:
=COUNT(D2:D4)
The last part of the formula is written in cell F2:
=IF(E2=3,A2&","&A3&","&A4,"")
The result of this formula, in column F, there are 7 cells that have three dates written in them, separated by a comma.
Note that you can make any character or string of text separate the three displayed dates by replacing the commas that are in-between the ampersand, quote text:
(&","&) can become (&"anything you want"&)
From here, auto-fill the formulas to the relevant cells.
EDIT:
One way to shorten the code is to add the COUNT formula into the last IF statement like this:
=IF(COUNT(D2:D4)=3,A9&","&A10&","&A11,"")
I do still think that the first IF statement will need to be separate from the rest of the formula, though.
EDIT #2
Here is the code in one single cell:
=IF(AND(B2>=30,B3>=30,B4>=30), A2&","&A3&","&A4,"")
Which will display three dates that are located within Column A, current row & the next two rows below it.
This code still produces 7 lines of results with the data that you've provided.

Extract two numbers out of a string in Excel

I have a string that I need two numbers extracted and separated into two columns like this.
ID:1234567 RXN:89012345
ID:12345 RXN:678901
Column 1 Column 2
1234567 89012345
12345 678901
The numbers can be varying number of characters. I was able to get column 2 number by using the following function:
=RIGHT(G3,FIND("RXN:",G3)-5)
However, I'm having a hard time getting the ID number separated.
Also, I need this to be a function as I will be using a macro to use over many spreadsheets.
A way to do this is:
Select all your data - assuming it is in a string all the time - which means one cell has one row with ID&RXN nos. So if you have 100 rows such data, select all of it
Go to the Data tab, Text to columns
Choose Delimited>>Next>> choose Space here, in Other, type a colon(:) >> Finish
You will get "ID" in first column, every cell; ID no in second column every cell; RXN in third column every cell and RXN no in 4th column every cell.
Delete unwanted columns
With data in column A, in B1 enter:
=MID(A1,FIND("ID:",A1)+LEN("ID:"),FIND(" ",A1,FIND("ID:",A1)+LEN("ID:"))-FIND("ID:",A1)-LEN("ID:"))
and copy down. In C1 enter:
=MID(A1,FIND("RXN:",A1)+LEN("RXN:"),9999)
and copy down:
The column B formulas are a pretty standard way to capture a sub-string encapsulated by two other sub-strings.
If your format is always as you show it,then:
B1: =TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1," ",REPT(" ",99)),":",REPT(" ",99)),99,99))
C1: =TRIM(MID(SUBSTITUTE(SUBSTITUTE($A1," ",REPT(" ",99)),":",REPT(" ",99)),3*99,99))
We substitute a long string of spaces for the space and : in the original string. Then we extract the 2nd and 4th items and trim off the extra spaces.

If third number is 1 then insert text X

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 !

Resources