• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Code

GN0001

Member
I am looking for VBA code that takes out the Carriage Return Character. I have a column that carriage return is unevenly coming in each row. How to take it out? VBA Code?
 
Guity


what about Replace


Variable = Replace(Variable, chr(10),"")

or

Variable = Replace(Variable, chr(13),"")
 
Hi Guity,

You can also use an in-cell formula.

Code:
=SUBSTITUTE(A1,CHAR(13),"")


Will do the same for cell A1.  Excel appears to remove the line break if you use either [code]CHAR(13) (carriage return) or CHAR(10)
(line feed).


If you want a space instead of a line break, you can use:

=SUBSTITUTE(A1,CHAR(13)," ")[/code]


Asa
 
Asa and Hui,


Thank you for the response. I have 3 carriage returns in one row, can I use SUBSTITUTE(A1,CHAR(13)," ") to remove all three in a row, while I have 50000 Rows?


If I want to use it in VBA, what would be the whole code?


Thank you very much.

Guity
 
Hi Guity, glad to help!


Don't be afraid to try it :)


Yes, substitute handles multiple instances.

If you want make the change permanent,

Copy the new calculated column, and paste it back with Paste Special/Values to remove the formulas.


It might be possible to use search and replace to remove line breaks as well (Ctrl-H)
 
Back
Top