VBA: carriage return in place of ;

Nelson78

Well-known Member
Joined
Sep 11, 2017
Messages
526
Office Version
  1. 2007
Hello everybody.

I have a range composed by cells with data separeted by ;

for example

125; 545; 5498; 154


Now, inside the cells, I need carriage returns to turn the text into this way:

125
545
5498
154



My unsuccessful attempt:

Code:
range.Replace what:=";", replacement:=vbNewLine, lookat:=xlPart, MatchCase:=False
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try
Code:
Selection.Replace what:="; ", replacement:=vbNewLine, lookat:=xlPart, MatchCase:=False
 
Upvote 0
Try
Code:
Selection.Replace what:="; ", replacement:=vbNewLine, lookat:=xlPart, MatchCase:=False

Analysing the problem, It is better to share something more.
In effect, I have this situation:

Code:
            If alpha(J, 1) = delta(i + 1, 1) Then
                delta(i + 1, 2) = delta(i + 1, 2) & [COLOR="#FF0000"]" ;"[/COLOR] & alpha(J, 2)
            End If

Now, the data are separated by ;.
I think it is more appropriate to intervene in this snippet.
 
Upvote 0
Code:
delta(i + 1, 2) = delta(i + 1, 2) & vbLf & alpha(J, 2)
 
Upvote 0

Forum statistics

Threads
1,215,509
Messages
6,125,216
Members
449,215
Latest member
texmansru47

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