Para Dante, Macro para Copiar celdas cobinadas de varias hojas y guardarlas en una hoja.

Hola! Dante

Con la pregunta ya expuesta, al ejecutar la macro que me diste me manda a error '1004' indicando que no se puede cambiar parte de una celda combinada en este caso como puedo trabajar con las celdas combinadas sin que este me mande a error , la macro que me diste fue el siguiente.

Sub CopiarDatos()
'Por.Dante Amor
    Application.ScreenUpdating = False
    Set h1 = Sheets("INGRESO DATOS")
    For Each h In Sheets
        If InStr(1, h.Name, ".") > 0 Then
            h.[L7,L11].Copy
            Set b = h1.Rows(51).Find(h.Name)
            If Not b Is Nothing Then
                h1.Cells(52, b.Column).PasteSpecial Paste:=xlPasteValues
            Else
                u = h1.Cells(51, Columns.Count).End(xlToLeft).Column + 1
                If u < 3 Then u = 3
                h1.Cells(51, u) = h.Name
                h1.Cells(52, u).PasteSpecial Paste:=xlPasteValues
            End If
        End If
    Next
    MsgBox "Copiar datos terminado"
End Sub

Cual seria el cambio de código que hay que realizar para que no mande a error.

las celdas "L7" y la celda "L11" son celdas que son combinadas.

1 respuesta

Respuesta
1

Te anexo la macro

Sub CopiarDatos()
'Por.Dante Amor
    Application.ScreenUpdating = False
    Set h1 = Sheets("INGRESO DATOS")
    For Each h In Sheets
        If InStr(1, h.Name, ".") > 0 Then
            celda7 = h.[L7]
            celda11 = h.[L11]
            Set b = h1.Rows(51).Find(h.Name)
            If Not b Is Nothing Then
                h1.Cells(52, b.Column) = h.[L7]
                h1.Cells(53, b.Column) = h.[L11]
            Else
                u = h1.Cells(51, Columns.Count).End(xlToLeft).Column + 1
                If u < 3 Then u = 3
                h1.Cells(51, u) = h.Name
                h1.Cells(52, u) = h.[L7]
                h1.Cells(53, u) = h.[L11]
            End If
        End If
    Next
    MsgBox "Copiar datos terminado"
End Sub

Recibe un cordial saludo y felices fiestas! Dante Amor

No olvides valorar la respuesta.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas