ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   find text in cell and replace it with part of the text in that ce. (https://www.excelbanter.com/excel-discussion-misc-queries/141381-find-text-cell-replace-part-text-ce.html)

Jules

find text in cell and replace it with part of the text in that ce.
 
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

RobN[_2_]

find text in cell and replace it with part of the text in that ce.
 
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

"jules" wrote in message
...
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




Gary''s Student

find text in cell and replace it with part of the text in that ce.
 
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

--
Gary''s Student - gsnu200718

Gary''s Student

find text in cell and replace it with part of the text in that ce.
 
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

--
Gary''s Student - gsnu200718


"jules" wrote:

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



All times are GMT +1. The time now is 04:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com