Brann
Brann

Reputation: 19

Excel: Delete ALL to the right of the right of particular first "character"

I need to delete all text to the right of the first "|" in a group of cells.

I had been using this:

=IFERROR(RIGHT(input,LEN(input)-FIND("stack",input)+1),"")

to delete to the left of a specific character. I found this in a stackoverflow question.

I am not sure how to make it so it reads to find the FIRST specific character. I also am trying to delete to the right of, but I believe I can fix that myself.

Thanks in advance

Upvotes: 1

Views: 3928

Answers (1)

pnuts
pnuts

Reputation: 59475

Assuming by the first "|" in a group of cells you mean the leftmost pipe character in each cell of an array of cells then as @Aprillion suggests =LEFT(A1,FIND("|",A1)-1) seems a good approach (where A1 is the first element of the array and the formula is copied across/down as appropriate).

If the group is a column, an alternative could be to use Data > Data Tools – Text to Columns with Delimited and Other: |, then delete inserted columns as required.

Upvotes: 1

Related Questions