Link to home
Start Free TrialLog in
Avatar of Alex Campbell
Alex CampbellFlag for United States of America

asked on

How to select one item in a cell value separated by characters?

I have a list of cities in this format in each cell:
Baltimore|Maryland|United States
Frederick|Maryland|United States
Chicago|Illinois|United States

I need a custom function to pull out the 2nd one in each cell.
Maryland
Maryland
Illinois
Parsing.xlsx
Avatar of Ejgil Hedegaard
Ejgil Hedegaard
Flag of Denmark image

Use this formula
=MID(A1,SEARCH("|",A1)+1,SEARCH("|",A1,SEARCH("|",A1)+1)-1-SEARCH("|",A1))

Or mark the items in column A and use the "Text to columns" function on the Data tab, and use | as delimiter.
Parsing.xlsx
Avatar of Alex Campbell

ASKER

Thank you for the suggestion of the formula.
I would like to see how it would work as a custom function.
That is because I am working on learning how to build custom functions.
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
wonderful. Just what I was looking for
I don't see how to ask a related question any more.
How could the function be adapted to pass the character to be used as the separator?
How could the function be adapted to pass the character to be used as the separator?

try change the 3rd parameter in that function, like:

=SplitString(A1,2, "*")

which means * is the separator
Great, thanks!
Great, thanks!