find last / and extract the value

nikhil0311

Board Regular
Joined
May 3, 2013
Messages
200
Office Version
  1. 2013
Platform
  1. Windows
[TABLE="width: 739"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD]Problem
[/TD]
[TD]Solution[/TD]
[/TR]
[TR]
[TD]sites/213870278/_catalogs/masterpage/display templates/filters
[/TD]
[TD]Filters[/TD]
[/TR]
[TR]
[TD]sites/213870278/_catalogs/masterpage/display templates/filters/control_refinement.js
[/TD]
[TD]control_refinement[/TD]
[/TR]
[TR]
[TD]sites/213870278/_catalogs/masterpage/display templates/filters/filter_default.js
[/TD]
[TD]filter_default[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 625"]
<tbody>[TR]
[TD]I have data in column A. and final output in Column B
[/TD]
[/TR]
[TR]
[TD]I want to find the last "/" and exclude "values after full stop" in column A and have the solution in Column B.
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]Criteria "Find last "/" and exclude value after "fullstop"
[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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]

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#70AD47]Column1[/td][td=bgcolor:#70AD47]Text Between Delimiters[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]sites/213870278/_catalogs/masterpage/display templates/filters[/td][td=bgcolor:#E2EFDA]filters[/td][/tr]

[tr=bgcolor:#FFFFFF][td]sites/213870278/_catalogs/masterpage/display templates/filters/control_refinement.js[/td][td]control_refinement[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]sites/213870278/_catalogs/masterpage/display templates/filters/filter_default.js[/td][td=bgcolor:#E2EFDA]filter_default[/td][/tr]
[/table]
 
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,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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