find text in cell and replace it with part of the text in that ce.

G

Guest

I have data in a cell eg Rewardsmax_dining_729x90_BUSFIN
I want to strip out the _729x90_BUSFIN.

How do I find and replace the contents of this column so that the only text
I keep is

Rewardsmax_dining

each cell in the column has Rewardsmax but each cell has unique text
associated with it. I need to strip out anything now Rewardsmax_dining
 
R

RobN

One way.

Select the cells (or the whole column), then using the Replace feature from
the menu bar, type in a single * in the From What: box and
Rewardsmax_dining in the Replace With: box and click Replace All.

Rob
 
G

Guest

Hi jules:

Select the cells you want to clean and run:

Sub reward()
Dim s As String
s = "Rewardsmax_dining_729x90_BUSFIN"
For Each r In Selection
If InStr(r.Value, s) <> 0 Then
r.Value = s
End If
Next
End Sub
 
G

Guest

This version will retain only the first part:

Sub reward()
Dim s As String
s = "Rewardsmax_dining"
For Each r In Selection
If InStr(r.Value, s) <> 0 Then
r.Value = s
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top