# Deleting text from a range of cells

#### cavesy

##### New Member
I am trying to delete some text from end of a range of cells. Sounds easy but brain fade has set in!
This is the contents of some of the cells

xyzabc/1.0.0.1/xyzabc/xyzabc.osd
abc/abc/2.0.0.12/abc/abc.osd
defghijk/1.2.11.21/defghijk/defghijk.osd

I want to delete the text after the last number. ie the last /*/*.osd, thus leaving

xyzabc/1.0.0.1
abc/abc/2.0.0.12
defghijk/1.2.11.21

I've tried using Find & Replace but can't find the key to doing it this way. Can't find any of the functions that may help me so I'm a bit stumped.

Any help would be appreciated
Thanks
Cavesy

### 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.
I think this does what you want, don't like the looping, there will be a better way, but hey, it works! Please tell me if it doesn't work.

I refrained from using InStrRev as I don't know what excel version you are using.

*************
Sub RemoveNumerics()
Dim rng As Range
Dim i As Integer

If TypeName(Selection) <> "Range" Then Exit Sub

For Each rng In Selection
Do While Not i = Len(rng.Value)
If IsNumeric(Mid(rng.Value, Len(rng.Value) - i, 1)) Then
rng.Value = Left(rng.Value, Len(rng.Value) - i)
Exit Do
Else
i = i + 1
End If
Loop
Next

End Sub
*************

Z

btw you'll need to select the cells you want to modify

A formula that will do this is

=LEFT(A2,FIND("/",RIGHT(A2,LEN(A2)-FIND("/",A2)))+FIND("/",A2)-1)

This assumes your data is A2, if not you will need to update all the A2 references.

Replies
1
Views
172
Replies
5
Views
793
Replies
6
Views
2K
Replies
3
Views
932
Replies
5
Views
2K

1,203,460
Messages
6,055,557
Members
444,797
Latest member
18ecooley

### 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.

### Which adblocker are you using?

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

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