View Single Post
 
Old 08-19-2014, 06:03 PM
ryanjohnsond@gmail.com ryanjohnsond@gmail.com is offline Windows 8 Office 2007
Novice
 
Join Date: Aug 2014
Posts: 18
ryanjohnsond@gmail.com is on a distinguished road
Default Run Script to remove carriage returns on certain columns

  1. How do I modify the Alexander Frolov VB code below to remove carriage returns on specific columns (i.e., with names, "Items" and "Sheet No.") and replace the carriage returns with commas (",")?
  2. I have about 50 Excel files like this. Is there a bulk way to run a script on all those files?

Code:
Sub RemoveCarriageReturns()
    Dim MyRange As Range
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
 
    For Each MyRange In ActiveSheet.UsedRange
        If 0 < InStr(MyRange, Chr(10)) Then
            MyRange = Replace(MyRange, Chr(10), ",")
        End If
    Next
 
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic
End Sub
The result should look like this:

| Sheet No.|
-----------
| 1 |
| 1 |
------------

(removes carriage return and replaces with comma) in column "


| Sheet No.|
-----------
| 1,1 |
------------
Reply With Quote