Macro excel para combinar celdas

Posted by Labels: at



 Para combinar la celda de arriba con la de abajo usar este macro 

____________________________________________

Sub Macro1()

'

' Macro1 Macro

' Combinar celdas

'

' Acceso directo: CTRL+x


   ActiveCell.Resize(2, 1).Merge

 

End Sub

____________________________________

O usar este como alternativa 


Sub CombinarCeldas()

 If Not ActiveCell.MergeCells Then

   ActiveCell.Resize(2, 1).Merge

 Else

   MsgBox "Celda ya..."

______________________________________


Recordar que la celda de abajo debe estar vacia. 


______________________________________

Para combinar las celdas seleccionadas dentro de una columna 


:Sub Macro1()

'

' Macro1 Macro

' combinar

'

' Acceso directo: CTRL+x

'



'UpdatebyExtendoffice20171025

    Dim I As Long

    Dim xRow As Long

    Dim xRg As Range

    Dim xCell As Range

    Dim xAddress As String

    On Error Resume Next

    xAddress = Application.ActiveWindow.RangeSelection.Address

    Set xRg = Application.InputBox("Select a range (single column):", "KuTools For Excel", xAddress, , , , , 8)

    If xRg Is Nothing Then Exit Sub

    If xRg.Columns.Count > 1 Then

        MsgBox "Only work for single column", , "KuTools For Excel"

        Exit Sub

    End If

    xRow = xRg.Rows.Count + 1

    Set xRg = xRg(xRow)

    For I = xRow To 1 Step -2

        Set xCell = xRg.Offset(I - xRow, 0)

        Debug.Print xCell.Address

        xCell.Resize(2, 1).Merge

    Next


End Sub


Back to Top