SEARCH - but from Right to Left...

Aitch

Board Regular
Joined
Jan 27, 2019
Messages
119
Office Version
  1. 2010
Platform
  1. Windows
I have data in a column which looks something like this:

1X3456789 - SEARCH ("X" , A1) = 2
234X73876 - SEARCH ("X" , A2) = 4
839030X38 - SEARCH ("X" , A3) = 7

Is there a way to SEARCH in reverse so it looks from Right to Left ??

1X3456789 - reverseSEARCH ("X" , A1) = 8
234X73876 - reverseSEARCH ("X" , A2) = 6
839030X38 - reverseSEARCH ("X" , A3) = 3


Thank you for any help!
 
This will get you the position of the rightmost "X":

Book2
AB
11X3456X897
2234XX38765
323X76X35X9
Sheet2
Cell Formulas
RangeFormula
B1:B3B1=IFERROR(AGGREGATE(14,6,ROW(INDIRECT("1:"&LEN(A1)))/(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)="X"),1),"")


If you want the second "X" from the right, change the 1 near the end of the formula to 2. If you want to find the nth "X" from the LEFT, change the 14 near the start to a 15.
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Here is another formula that you can consider...

=IF(COUNTIF(A1,"*X*"),1+LEN(TRIM(RIGHT(SUBSTITUTE(A1,"X",REPT(" ",99)),99))),"")
 
Upvote 0
.. and another one

Edit: Oops, sorry, I thought the OP had Excel 365 but I see that is not so. Still I'll leave it in case use for others.

20 08 04.xlsm
AB
11X3456X893
2234XX38765
323X76X35X1
Reverse search
Cell Formulas
RangeFormula
B1:B3B1=MATCH(88,CODE(RIGHT(A1,SEQUENCE(99))),0)
 
Upvote 0
So if not Excel 365, a couple of other options.
May require Ctrl+Shift+Enter confirmation in other Excel versions.
One is volatile but string can be any length
The other is not volatile but only deals with strings up to 9 characters (which is what all the OP's samples were)

20 08 04.xlsm
ABC
11X3456X8933
2234XX387655
323X76X35X11
Reverse search
Cell Formulas
RangeFormula
B1:B3B1=MATCH(88,CODE(RIGHT(A1,ROW(INDIRECT("1:"&LEN(A1))))),0)
C1:C3C1=MATCH(88,CODE(RIGHT(A1,{1,2,3,4,5,6,7,8,9})),0)
 
Upvote 0
These work great! (Hopefully I'll figure out how they work at some point lol!)

Much appreciated guys!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,883
Messages
6,127,544
Members
449,385
Latest member
KMGLarson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top