Remove all text before character, when character appears multiple times

ladyredbull115

New Member
Joined
Nov 29, 2016
Messages
9
I have many rows that contain a file path which are all different and I need to end up with only the text after the last \

For example:

c:\users\user.name\appdata\roaming\baidu\baidurjdownloader\1.6.0.77\bdrcdl.exe

The cells after the file path contain counts of times this location was accessed.

Essentially, I am looking to remove all of the text before bdrcdl.exe so that I can create a pivot table and sum up all of the counts of bdrcdl.exe

I tried =RIGHT(A29,LEN(A29)-FIND("",A29)) but that only removes the text before the first ""
Converting the text to columns works, but since each file path is a different length, it spreads the text so that I can't easily gather what I need.

Thinking I need to a macro to loop through the nested function I tried, but I am still new to VBA and not really sure where to start on that one.

Any suggestions will be greatly appreciated.


<tbody>
</tbody>
 
I have many rows that contain a file path which are all different and I need to end up with only the text after the last \

For example:

c:\users\user.name\appdata\roaming\baidu\baidurjdownloader\1.6.0.77\bdrcdl.exe

The cells after the file path contain counts of times this location was accessed.

Essentially, I am looking to remove all of the text before bdrcdl.exe so that I can create a pivot table and sum up all of the counts of bdrcdl.exe

<tbody>

You want to remove that text directly within the cells containing the text, correct? If so, select the column with your text, press CTRL+H to bring up Excel's Replace dialog box, put "*" (without the quote marks) in the "Find what" field, leave the "Replace with" field empty, click the "Options>>" button and make sure there is no check mark in the Checkbox labeled "Match entire cell contents", and finish off by clicking the "Replace All" button.

If you really need this as a macro (and assuming your text is in Column A)...
Code:
Sub GetFileName()
  Columns("A").Replace "*\", "", xlPart
End Sub
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
MickG thanks very much. This worked as expected.

I Imagine you have some Blank rows !!!
Try this:-
Code:
[COLOR=Navy]Sub[/COLOR] MG29Nov18
[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(Range("A1"), Range("A" & Rows.Count).End(xlUp))
[COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] Dn [COLOR=Navy]In[/COLOR] Rng
 [COLOR=Navy]If[/COLOR] Not Dn.Value = vbNullString [COLOR=Navy]Then[/COLOR]
    Sp = Split(Dn.Value, "\")
    Dn.Value = Sp(UBound(Sp))
 [COLOR=Navy]End[/COLOR] If
[COLOR=Navy]Next[/COLOR] Dn
[COLOR=Navy]End[/COLOR] [COLOR=Navy]Sub[/COLOR]
Regards Mick
 
Upvote 0
Thanks Rick Rosthstein, this also would work. I did not realize excel allowed the wildcard characters in the find and replace box.
 
Upvote 0

Forum statistics

Threads
1,214,940
Messages
6,122,361
Members
449,080
Latest member
Armadillos

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