find last / and extract the value

nikhil0311

Board Regular
Joined
May 3, 2013
Messages
197
Office Version
  1. 2013
Platform
  1. Windows
Problem
Solution
sites/213870278/_catalogs/masterpage/display templates/filters
Filters
sites/213870278/_catalogs/masterpage/display templates/filters/control_refinement.js
control_refinement
sites/213870278/_catalogs/masterpage/display templates/filters/filter_default.js
filter_default

<colgroup><col><col></colgroup><tbody>
</tbody>

I have data in column A. and final output in Column B
I want to find the last "/" and exclude "values after full stop" in column A and have the solution in Column B.
Criteria "Find last "/" and exclude value after "fullstop"

<tbody>
</tbody>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
try PowerQuery

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Inserted Text Between Delimiters" = Table.AddColumn(#"Changed Type", "Text Between Delimiters", each Text.BetweenDelimiters([Column1], "/", ".", {0, RelativePosition.FromEnd}, 0), type text)
in
    #"Inserted Text Between Delimiters"[/SIZE]

Column1Text Between Delimiters
sites/213870278/_catalogs/masterpage/display templates/filtersfilters
sites/213870278/_catalogs/masterpage/display templates/filters/control_refinement.jscontrol_refinement
sites/213870278/_catalogs/masterpage/display templates/filters/filter_default.jsfilter_default
 
Upvote 0
This should do what you want !!
Results in column "B"
Code:
[COLOR="Navy"]Sub[/COLOR] MG24Aug49
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Sp [COLOR="Navy"]As[/COLOR] Variant
[COLOR="Navy"]Set[/COLOR] Rng = Range("A2", Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    Sp = Split(Dn.Value, "/")
    Dn.Offset(, 1).Value = Split(Sp(UBound(Sp)), ".")(0)
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
This is a UDF (User
Defined
Function) which should do the trick as well

Code:
Function LastValue(Txt As String) As String
LastValue = Split(Txt, "/")(UBound(Split(Txt, "/")))
If InStr(1, LastValue, ".") > 0 Then LastValue = Split(LastValue, ".")(0)
End Function



Book1
AB
1ProblemSolution
2sites/213870278/_catalogs/masterpage/display templates/filtersfilters
3sites/213870278/_catalogs/masterpage/display templates/filters/control_refinement.jscontrol_refinement
4sites/213870278/_catalogs/masterpage/display templates/filters/filter_default.jsfilter_default
Sheet1
Cell Formulas
RangeFormula
B2=LastValue(A2)
<strike></strike>
 
Upvote 0
Hi,

Here's a formula solution:


Book1
AB
1ProblemResults
2sites/213870278/_catalogs/masterpage/display templates/filtersfilters
3sites/213870278/_catalogs/masterpage/display templates/filters/control_refinement.jscontrol_refinement
4sites/213870278/_catalogs/masterpage/display templates/filters/filter_default.jsfilter_default
Sheet206
Cell Formulas
RangeFormula
B2=TRIM(LEFT(SUBSTITUTE(RIGHT(SUBSTITUTE(A2,"/",REPT(" ",100)),100),".",REPT(" ",200)),200))


Formula copied down.
 
Upvote 0
@mse330 and jtakw,

Both of your solutions will fail if the filename contains a dot within it (for example, filters.one.js just to make up a filename).



@everyone,

Here is a UDF which works around the above possible problem...
Code:
[table="width: 500"]
[tr]
	[td]Function FileName(FullPath As String) As String
  FileName = Mid(FullPath, InStrRev(FullPath, "/") + 1)
  If InStr(FileName, ".") Then FileName = Left(FileName, InStrRev(FileName, ".") - 1)
End Function[/td]
[/tr]
[/table]
 
Upvote 0
Thanks Rick, but all OP said was
Criteria "Find last "/" and exclude value after "fullstop"

So when OP clarifies if there's that possibility as you mentioned, and he wants to exclude Only after the Last "fullstop", I'll try to adjust my formula to suit. :)
 
Upvote 0
Thanks Rick, but all OP said was

So when OP clarifies if there's that possibility as you mentioned, and he wants to exclude Only after the Last "fullstop", I'll try to adjust my formula to suit. :)
To be fair, I did refer to it as a "possible problem"... I just wanted the OP to be alerted just in case.
 
Upvote 0
Thanks All. Really appreciate your support and help :). God bless us ALL
 
Upvote 0

Forum statistics

Threads
1,215,338
Messages
6,124,349
Members
449,155
Latest member
ravioli44

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