Search through a string of text for a specific value and relate it to a horizontal value

%3CLINGO-SUB%20id%3D%22lingo-sub-2259049%22%20slang%3D%22en-US%22%3ESearch%20through%20a%20string%20of%20text%20for%20a%20specific%20value%20and%20relate%20it%20to%20a%20horizontal%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2259049%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20create%20a%20script%20that%20allows%20me%20to%20type%20in%20the%20unique%20ID%20in%20a%20cell%20and%20have%20it%20spit%20out%20the%20value%20of%20the%20product%20name%20in%20the%20horizontal%20row%20corresponding%20to%20the%20unique%20ID.%20The%20main%20catch%20here%20is%20that%20sometimes%20the%20input%20number%20is%20a%20lot%20longer%20than%20the%20unique%20ID.%20The%20only%20value%20I%20need%20as%20the%20output%20is%20the%20product%20name.%20The%20input%20number%20will%20still%20have%20a%20corresponding%20Unique%20ID%2C%20just%20with%20a%20longer%20number%20sequence%20in%20the%20front%20and%20backside%20of%20it.%20Basically%2C%20I%20need%20to%20be%20able%20to%20search%20through%20the%20unique%20ID%20list%20to%20see%20if%20any%20one%20of%20those%20values%20is%20integrated%20into%20the%20longer%20input%20value.%20For%20example%2C%20if%20my%20input%20number%20is%20%221234%2C%22%20the%20code%20will%20have%20to%20know%20it%20is%20referring%20to%20unique%20ID%20%2223%2C%22%20since%20%2223%22%20is%20in%20between%20%221234.%22%20I%20have%20a%20screenshot%20of%20the%20code%20I%20have%20right%20now.%20Anything%20helps.%20Thanks.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22connerh99_1-1617809182835.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F270777i01383868BE939BA4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22connerh99_1-1617809182835.png%22%20alt%3D%22connerh99_1-1617809182835.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2259049%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2259059%22%20slang%3D%22en-US%22%3ERe%3A%20Search%20through%20a%20string%20of%20text%20for%20a%20specific%20value%20and%20relate%20it%20to%20a%20horizontal%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2259059%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1019530%22%20target%3D%22_blank%22%3E%40connerh99%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESorry%2C%20I%20can%20recognize%20nothin%20in%20your%20screenshot%2C%20perhaps%20you%20may%20submit%20sample%20file%20with%20the%20same%20information.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am trying to create a script that allows me to type in the unique ID in a cell and have it spit out the value of the product name in the horizontal row corresponding to the unique ID. The main catch here is that sometimes the input number is a lot longer than the unique ID. The only value I need as the output is the product name. The input number will still have a corresponding Unique ID, just with a longer number sequence in the front and backside of it. Basically, I need to be able to search through the unique ID list to see if any one of those values is integrated into the longer input value. For example, if my input number is "1234," the code will have to know it is referring to unique ID "23," since "23" is in between "1234." I have a screenshot of the code I have right now. Anything helps. Thanks.

connerh99_1-1617809182835.png

 

 

3 Replies

@connerh99 

Sorry, I can recognize nothin in your screenshot, perhaps you may submit sample file with the same information.

@connerh99 

I can hardly see your image but i think you have to reverse the search if you want to use wildcard (look for the value from A1:A120 in G3). This should give you the first match 

=MATCH(1,isnumber(search("*"&A2:A130&"*",G3))*(A2:A130<>""),0)

"*"&A2:A120&"*" will create a wildcard string (*23*) and look in the text value  in G3

"'"&G3  ('1234).

Match will return the position of the first value that gives a "1"

Alternative

=MATCH(1,XMATCH("*"&A2:A120&"*","'"&G3,2),0)

Add index.

=INDEX(B2:B120,MATCH(1,isnumber(search("*"&A2:A130&"*",G3))*(A2:A130<>""),0))

 

As for the rest of the code (the row(xxx))  im lost

 

You might want to add some kind of count. just to make sure you get uniqe hits

sum(isnumber(search("*"&A2:A130&"*",G3))*(A2:A130<>""))

 

For one thing, your formula has "IANUMBER" instead of ISNUMBER and is why you are getting #NAME.