View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.misc
Ken Johnson
 
Posts: n/a
Default Excel should merge cells without removing content of any cell

Hi Richard,

This is the same, I've just included a line break in the long line that
wrapped in the post, which causes a problem when you copy and paste the
code into Excel.

Public Sub CutPaste_ColB_into_ColA()
Application.ScreenUpdating = False
Dim iRows As Long
Dim iColumns As Long
Dim vaMergeArray As Variant
Dim I As Long
vaMergeArray = Selection
iRows = Selection.Rows.Count
iColumns = Selection.Columns.Count
If iColumns < 2 Then Exit Sub
For I = 1 To iRows
vaMergeArray(I, 1) = vaMergeArray(I, 1) _
& Space(1) & vaMergeArray(I, 2)
vaMergeArray(I, 2) = ""
Next I
Selection = vaMergeArray
Selection.Columns.AutoFit
If Application.CountA(ActiveCell.Offset(0, 1).EntireColumn) = 0 Then
ActiveCell.Offset(0, 1).EntireColumn.Delete
End If
End Sub

Ken Johnson