Sunday, August 24, 2014

Excel Macro: Combine two cell without losing

Macro code:
Sub Combine()
    Dim vCell As Long
    Dim lastcolumn As Long

lastcolumn = Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
   
    For vCell = 1 To lastcolumn
        If Cells(6, vCell) = "" Then
           
        Else
            Cells(6, vCell).Value = _
            Cells(6, vCell).Value & " " & _
            Cells(5, vCell).Value
            Cells(5, vCell).Clear
        End If
    Next vCell


End Sub

No comments:

Post a Comment