Find TEXT, WITH Text Carriage return

jamada

Active Member
Joined
Mar 23, 2006
Messages
323
Hi there

Within a cell when the text "FOLLOW-UP" is found, WITH this text I would like to move "FOLLOW-UP" (And The TEXT following it) to start a new line.

This does not seem to work???


Dim SearchName As String
SearchName = "FOLLOW-UP"

For Each cell In ActiveSheet.Range("J2:J" & lr)
If InStr(1, cell, "SearchName", vbTextCompare) Then

With SearchName
vbNewLine (Chr(10))
End With
End If

Next
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Code:
    [COLOR=darkblue]Dim[/COLOR] SearchName [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
    SearchName = "FOLLOW-UP"
    
    [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] cell [COLOR=darkblue]In[/COLOR] ActiveSheet.Range("J2:J" & lr)
        [COLOR=darkblue]If[/COLOR] InStr(1, cell, [B]SearchName[/B], vbTextCompare) [COLOR=darkblue]Then[/COLOR]
            [B]cell.Value = Replace(cell.Value, SearchName, vbLf & SearchName, Compare:=vbTextCompare)[/B]
        [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]Next[/COLOR]

This would do the same thing...
Code:
    Range("J:J").Replace "FOLLOW-UP", vbLf & "FOLLOW-UP", xlPart, , [COLOR=darkblue]False[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,529
Messages
6,125,344
Members
449,219
Latest member
Smiqer

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