Código VBA para acumular datos de otras hojas en una sola!

Para Dante Amor!

Hola saludos de nuevo necesitando tus conocimientos!

Dante la situación es la siguiente tengo varias hojas con muchos datos los cuales quisiera recopilar en una sola hoja tal y como están en las hojas originales!

Aclaro que todas las hojas tienen el mismo formato lo único que varia son las cantidades de registros!

Sin más a que hacer mención me despido!

1 Respuesta

Respuesta
1

H o l a:

Te anexo la macro

Private Sub CommandButton1_Click()
'Por.Dante Amor
    'Actualizar Bitácora
    Set h2 = Sheets("BITACORA")
    u2 = h2.Range("B" & Rows.Count).End(xlUp).Row
    If u2 < 9 Then u2 = 9
    h2.Range("B9:G" & u2).Clear
    h2.Range("B9:G" & u2).Interior.ColorIndex = 1
    '
    For Each h1 In Sheets
        For m = 1 To 12
            mes = UCase(Format(DateSerial(Year(Date), m, 1), "mmmm"))
            If mes = UCase(h1.Name) Then
                u1 = h1.Range("B" & Rows.Count).End(xlUp).Row
                u2 = h2.Range("B" & Rows.Count).End(xlUp).Row + 1
                If u1 < 10 Then u1 = 10
                If u2 < 10 Then u2 = 10
                h1.Range("A10:F" & u1).Copy h2.Range("B" & u2)
                Exit For
            End If
        Next
    Next
    '
    u2 = h2.Range("B" & Rows.Count).End(xlUp).Row
    wtot = WorksheetFunction.Sum(h2.Range("G9:G" & u2))
    h2.Range("B" & u2 + 1) = "TOTAL GASTOS DEL MES"
    h2.Range("G" & u2 + 1) = wtot
    With h2.Range("B" & u2 + 1 & ":G" & u2 + 1)
        .Font.ColorIndex = 5
        .Font.Size = 14
        .Font.Bold = True
        .NumberFormat = "#,##0.00"
    End With
    MsgBox "Bitácora actualizada", vbInformation, "ACTUALIZAR BITÁCORA"
End Sub

':)
'S aludos. D a n t e   A m o r . R ecuerda valorar la respuesta. G racias
':)

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas