Question

Ok so,

In column A basically every cell has a different composition and doesn't have the same string Before And After the value we are looking to extract. For Example:

ODODODODEFGH4OGOGOG

LALALALALABCDE12-1ALALALALA

IRIRIRIRIJKLMNOROROR

And I need to extract the following strings which are located in another sheet ((its an SKU information combining text and numbers with variable length) from column A and list it in the column B next to it

ABCDE12-1

EFGH4

IJKLMN

I've tried Find, Mid, Lookup, Index functions but can't seem to find the solution. Any help very appreciated!

Was it helpful?

Solution

Let's say your Sheet1 and Sheet2 looks like this.

enter image description here

Put this formula in Cell B1 of Sheet1 and pull it down.

=IF(SUMPRODUCT(COUNTIF(A1,"*"&Sheet2!$A$1:$A$3&"*")),INDEX(Sheet2!A:A,SUMPRODUCT(COUNTIF(A1,"*"&Sheet2!$A$1:$A$3&"*")*ROW(Sheet2!$A$1:$A$3))),"")

enter image description here

OTHER TIPS

OK, now that we know you have a lookup table, set up the following:

On Some sheet, list your valid SKU's in a vertical Named Range. e.g: ValidSKU refers to: Sheet2!$A$2:$A$100

Then with your gibberish string on some sheet in A1, to return the valid SKU from the string:

B1:  =INDEX(ValidSKU,LOOKUP(9E+307,FIND(ValidSKU,A1),ROW(INDIRECT("1:10000"))))

The "10000" argument in the above formula needs to be a number that is at least as large as the number of SKU's in your list. So if you have 5000 valid SKU's, use some number greater than that.

Then fill down as far as needed.

This method has a weakness: If there are overlapping SKU's, it will return the lowest one that matches. So it would be best to have your longest SKU's at the bottom of the list.

In other words, if you have two SKU's ABCDE12-1, and ABCDE12, both of those are found in your 2nd string. Whichever is located last in the ValidSKU list will be the one returned. I don't know of any way (other than position) to differentiate these two possibilities.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top