Forum Discussion
Categorizing in Excel
- Jun 11, 2020
lucahla Sorry to interrupt, but have you had a chance to look at the file I sent earlier? It contains a list where you can enter the snippets you indexed. The formula (in B2 and copied down)
=IFERROR(MATCH(TRUE,(ISNUMBER(SEARCH($D$2:$D$7,A2,1))),0),"")
will give you the position in the list when a snippet is found in the text in A. Just amend to cell references and list range to fit your real worksheet.
Now, you added another dimension to your question by stating that the snippets are always in the last two positions of the text. In that case you could expand the reference to A2 in the above formula to become RIGHT(A2,2) . This will avoid incorrect indexing in case your text would be like "ABC3456-78_9 DE" where it would pickup the BC as the snippet, assuming your snippet-list is alphabetically sorted. Can even think of some more variations to avoid this. Not sure, though, that this could ever occur. So, perhaps it's totally irrelevant.
- lucahlaJun 10, 2020Copper Contributor
they are 6 to 7 digit long combinations of numbers and text, then there is a space, and then there is the snippet that has to be indexed, so, with an example snippet "AB":
"12k45f7 AB". The letter/digit combinations can be ignored, I just want to index/categorise the snippets. So, said in a text form, something like:
"if cell C4 contains the the letter combination that reads "AB" (just as an example), then you should output number "3" (example) to cell D4."
- mtarlerJun 10, 2020Silver Contributor
lucahla can you just show that snippet? so a formula like:
=MID(C4,SEARCH(" ",C4)+1,99)
- lucahlaJun 10, 2020Copper Contributor
yes, I can show a snippet that looks like mine (I can't share any original text or numbers).
So, let's assume C2 contains "A123456-78_9 BC".
Let's also say C3 contains "A987654-32_1 DE".
I then want to have Excel give me
for D2: "1"
for D3: "2"
etc.
also, to clarify: there are roughly 500-1000 rows that look like this, each one with slightly different combinations, but the last 2 signs are alwas one of only 6 different options.
Do you see what I mean? Thank you in advance!