Look for values in a string

%3CLINGO-SUB%20id%3D%22lingo-sub-2678489%22%20slang%3D%22en-US%22%3ELook%20for%20values%20in%20a%20string%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2678489%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everybody%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20set%20a%20formula%20that%20allows%20me%20to%20find%20some%20values%20in%20a%20string%20and%20gives%20back%20the%20requested%20values.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20column%20Specification%20contains%20some%20%23%20followed%20by%20ID%20plus%20letters%2Fnumbers.%20I%20would%20need%20to%20create%20a%20new%20column%20that%20gives%20back%20only%20the%20%23ID.%26nbsp%3B%3C%2FP%3E%3CP%3EBasically%20the%20formula%20should%20do%3A%20search%20in%20column%20A%20for%20C2%20and%20giveback%20D2%2C%20or%20search%20C3%20and%20give%20back%20D3%2C%20and%20so%20on%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ecould%20you%20please%20support%20with%20that%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AndreaBruneo_1-1629798763184.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F305336iB2C3C689493B601B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22AndreaBruneo_1-1629798763184.png%22%20alt%3D%22AndreaBruneo_1-1629798763184.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Emany%20thanks%20%3A))%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2678489%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2679160%22%20slang%3D%22en-US%22%3ERe%3A%20Look%20for%20values%20in%20a%20string%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2679160%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1136051%22%20target%3D%22_blank%22%3E%40AndreaBruneo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECould%20you%20please%20indicate%20on%20which%20version%20of%20Excel%20you%20are%20and%20what%20exactly%20shall%20be%20returned%20for%20each%20row%20in%20your%20sample.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2679780%22%20slang%3D%22en-US%22%3ERe%3A%20Look%20for%20values%20in%20a%20string%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2679780%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1136051%22%20target%3D%22_blank%22%3E%40AndreaBruneo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3CBR%20%2F%3ESimple%20version%3A%3CBR%20%2F%3E%3DMID(A1%3BFIND(%22%23%22%3BA1)%3BFIND(%22%20%22%3BA1%3BFIND(%22%23%22%3BA1))-FIND(%22%23%22%3BA1))%3C%2FP%3E%3CP%3Eit%20assumes%20that%20%23ID%20ends%20with%20space%20character.%3CBR%20%2F%3EBut%20if%20your%20data%20can%20be%20more%20complicated%20think%20of%20regex%20dark%20power.%20You%20can%20find%20examples%20of%20UDF%20functions%20and%20how%20to%20use%20them%20on%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F22542834%2Fhow-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F22542834%2Fhow-to-use-regular-expressions-regex-in-microsoft-excel-both-in-cell-and-loops%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EArtur%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi everybody,

 

I am trying to set a formula that allows me to find some values in a string and gives back the requested values. 

 

The column Specification contains some # followed by ID plus letters/numbers. I would need to create a new column that gives back only the #ID. 

Basically the formula should do: search in column A for C2 and giveback D2, or search C3 and give back D3, and so on

 

could you please support with that?

 

AndreaBruneo_1-1629798763184.png

 

many thanks :))

4 Replies

@AndreaBruneo 

Could you please indicate on which version of Excel you are and what exactly shall be returned for each row in your sample.

@AndreaBruneo 

Hi,
Simple version:
=MID(A1;FIND("#";A1);FIND(" ";A1;FIND("#";A1))-FIND("#";A1))

it assumes that #ID ends with space character.
But if your data can be more complicated think of regex dark power. You can find examples of UDF functions and how to use them on https://stackoverflow.com/questions/22542834/how-to-use-regular-expressions-regex-in-microsoft-excel... 

Regards

Artur

Hi Sergei, thank you for answering.

Excel version 2107

The returned value should be the value in D2 when the formula finds C2 or D3 when finds C3 ( and so on) in the string in column A:A

@AndreaBruneo 

Thank you, so you are on Excel 365.

As for sample - sorry, I still don't understand. In the sample we have 5 records in A2:A6. Formula shall search text "#IC" (C2) in above range and return in D2 same text "IC". Why? Where is no "#IC" in A2:A6.

 

Or, if "#IC" is not found we shall check next (in C3), also nothing, finally we find "#OT" from C3 - are sure we shall return the same string into D3?