0

How do I get a specific text only like "LHS" or "RHS"?

Thank you for helping.

enter image description here

4
  • You want to use LEFT or RIGHT and probably FIND. See this site Commented May 19, 2021 at 19:44
  • What do you mean extract it? If the cell contains RHS then say RHS else if it contains LHS then say LHS. Unless you're needing the index I don't see why you would complicate this. Commented May 19, 2021 at 20:07
  • Or you could just REPLACE RHS or LHS with empty string if wanting to rid it from the cell Commented May 19, 2021 at 20:08
  • Oops I meant SUBSTITUTE like this =SUBSTITUTE(A1, " RHS ", " ") Commented May 19, 2021 at 20:13

2 Answers 2

1

Provided that there are no other 3 character combinations ending with HS you can use: =MID(A1,SEARCH("?HS",A1)+1,3)

If you want to be sure to only find LHS or RHS use: =MID(A1,IFERROR(SEARCH("LHS",A1),SEARCH("RHS",A1))+1,3)

(Change A1 in the formula to the cell you like to search in)

Edit: Left out spaces in front and after search value to find result at end of beginning of text

Edit2: Added the spaces again, implementing Chris Neilsen's workaround: =MID(" "&A1&" ",IFERROR(SEARCH(" LHS "," "&A1&" "),SEARCH(" RHS "," "&A1&" "))+1,3)

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you. I tried the formula and working perfect fine for middle sentence; however, there is an error if the RHS or LHS appears in front or end of the sentence. since cant find the values for it dues to no space in front or end of the string.
@Kaiser ^^^ then replace A1 in the formula with " "&A1&" "
Ok, I removed the spaces, but then I recommend using the latter function.
And implemented Chris Neilsen's workaround in Edit2, because that's the nicest way.
0

In B2, formula copied down :

=MID(A2,MIN(SEARCH({"lhs","rhs"},A2&"lhsrhs")),3)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.