Macro to remove <enter> in an address line

MarkSpencer

New Member
Joined
May 10, 2005
Messages
25
I have a CSV file that has data exported that includes addresses. If the address line had a second row, it is all in one cell with a special character at the end of the first row of data. I am trying to record a macro to remove the special character. I put the cursor in the cell that needs editing, then do the following:

Start Recording
Press "Use Relative References" (because I want to just go down the list and do this for each line that needs it)

Then for the macro, I perform the following steps:
Press F2 to edit the cell
Press Ctrl+Home to go to top left corner of cell
Press End to go to end of the first line
Press Backspace to delete the special character.
Press Space to insert one space
Press Delete to bring the second line up to the first line
Prese Enter to exit editing and move down.

Press Stop Recording

My problem is that when I try to run the macro on the next cells, it simply pastes the value from the cell that it was on when I recorded the macro.

What am I doing wrong?
 
Last edited:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try selecting the range then running this

Code:
Sub RemLF()
Dim c As Range
For Each c In Selection
    c.Value = Replace(c.Value, vbLf, " ")
Next c
End Sub
 
Upvote 0
That brought the second line up to the end of the first, but the special character (it is a question mark inside a rectangle) still shows and prints.
 
Upvote 0
In the code try replacing VBLf with vbCr. If that still doesn't work try vbCrLf
 
Upvote 0
vbCrLf worked as needed.

vbCr removed the special character but left the data on two rows.

THANK YOU so much for your help and quick response!
 
Upvote 0

Forum statistics

Threads
1,216,174
Messages
6,129,296
Members
449,498
Latest member
Lee_ray

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