Solved

VBA that will replace line skips with commas

Posted on 2010-08-20
4
401 Views
Last Modified: 2012-05-10
I have a bunch of cells with line skips in them, as shown below only with the square symbol displayed after each number. I need a simple code that will convert all of them to commas followed by a space, as in: 17A, 17K, 18A ... etc.

Thanks,
John




... NO POWER 15H

17A

17K

18A

18C

18G

Open in new window

0
Comment
Question by:gabrielPennyback
4 Comments
 
LVL 14

Expert Comment

by:peetjh
ID: 33487853
I believe you can go to edit and replace and copy the symbol you want to remove and paste it into the find what and replace it with the comma.
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 33488436
John,A simple formula will do it, assuming you mean ANSI 10 for the "line skip" (that's what Excel uses for an in-cell line break).=SUBSTITUTE(A2,CHAR(10),", ")In code you could use the Replace method, as below.Patrick
ActiveSheet.UsedRange.Replace Chr(10), ", "

 

' note how the Excel function is CHAR while the VBA function is Chr  :)

Open in new window

0
 
LVL 1

Author Comment

by:gabrielPennyback
ID: 33686580
Yes, please award the points to Patrick, his answer works perfectly.
Thanks,
John
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now