Sorter Formula

Rubber Beaked Woodpecker

Board Regular
Joined
Aug 30, 2015
Messages
203
Office Version
  1. 2021
The following formula works very well but just curious if there is an easier/shorter way of writing the formula?

=IF(AND(LEFT(A65,1)="1",(RIGHT(A65,1)<>"t")),SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A65,"1",""),"2",""),"3",""),"4",""),"5",""),"6",""),"7",""),"8",""),"9",""),"/",""),"")

Thanks

RBW
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Personally, I would use a UDF. Something like this:
VBA Code:
Function RBW(r As Range) As String
    Dim i As Long, s As String, a
    a = Array("1", "2", "3", "4", "5", "6", "7", "8", "9")
    If Left(r, 1) = 1 And Right(r, 1) <> "t" Then
        s = r.Value
        For i = LBound(a) To UBound(a)
            s = Replace(s, a(i), "")
        Next
        RBW = Trim(s)
    Else
        RBW = r
    End If
End Function

Then the formula becomes simpler to enter:
Book1
AB
113 leave 1111leave
2leave 123 123leave 123 123
3123 leaveleave
41 321 312 321 312 
5321 321 321 t321 321 321 t
61 999 111 ttt 999ttt
7123456789 
8123456789 t123456789 t
Sheet1
Cell Formulas
RangeFormula
B1:B8B1=RBW(A1)
 
Upvote 0

Forum statistics

Threads
1,216,038
Messages
6,128,450
Members
449,453
Latest member
jayeshw

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