Forum Discussion
BAWrites
Jan 22, 2024Copper Contributor
Split a string by delimited characters and choose nth position in string
Looking for an excel formula that will take a string similar to this Instance >> Chain >> TimeZone >> State >> City >> Number >> Number2 And be able to output only the first "Number" occurren...
smylbugti222gmailcom
Jan 23, 2024Iron Contributor
Here's a formula that will extract the first "Number" occurrence from the string:
Excel=MID(A1,FIND("Number",A1)+7,FIND(">>",A1,FIND("Number",A1)+7)-FIND("Number",A1)-7)
Explanation:
- FIND("Number",A1): Finds the position of the first "Number" within the string.
- MID(A1,...,...): Extracts a substring from the original string.
- +7: Skips the characters "Number >" to get to the actual number.
- FIND(">>",A1,FIND("Number",A1)+7): Finds the position of the next ">>" after the first "Number".
- -FIND("Number",A1)-7: Subtracts the lengths of "Number >" and the first "Number" to determine the length of the number you want to extract.
Example:
If your string is in cell A1:
Instance >> Chain >> TimeZone >> State >> City >> Number 123 >> Number2
The formula will return:
123
Key points:
- Adjust the cell reference (A1) to match the cell containing your string.
- If the structure of your strings might vary, consider using more robust string manipulation techniques, such as combining FIND, LEFT, RIGHT, and LEN functions.