Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Complementar macro para copiar rangos

publicado

Buenos días tengo la siguiente macro.

 La idea es copiar rangos de todas las hojas a la Hoja1 una debajo de otra.

ésta es la macro solo me funciona en la primera copia, estaré agradecido.

Sub copiar()
    Set h1 = Sheets("Hoja1") ' hoja principal
    '
    dato = Array("C1:D5", "A1:B5", "H1:I5")
    '
    For Each h In ThisWorkbook.Sheets
    If h.Name <> h1.Name Then
        u = h1.Range("A" & Rows.Count).End(xlUp).Row
        For j = LBound(dato) To UBound(dato)
             h.Range(dato(j)).Copy h1.Range("A" & u)
             u = u + 1
        Next j
    End If
    Next h
End Sub


 

MACRO COPIAR.xlsm

Featured Replies

publicado
  • Autor

asssu acertado tu respuesta gracias 

publicado
  • Autor

Hola pero tengo otra duda que cada rango pertenece a una hoja como sería ?

intenté así

Sub copiar()
    Set h1 = Sheets("Hoja1") ' hoja principal
    '
    hoja = Array("Hoja2", "Hoja3", "Hoja4")
    dato = Array("A1:B5", "C1:D5", "H1:I5")
    '
    For Each h In ThisWorkbook.Sheets
    
        If h.Name <> h1.Name Then
            u = h1.Range("A" & Rows.Count).End(xlUp).Row
            '
            For i = LBound(hoja) To UBound(hoja)
                For j = LBound(dato) To UBound(dato)
                     h(i).Range(dato(j)).Copy h1.Range("A" & u)
                     u = u + h.Range(dato(j)).Rows.Count
                Next j
            Next i
            '
        End If
    
    Next h
End Sub

 

publicado
  • Autor

 

Hace 19 horas, bigpetroman dijo:

no, asi tal como está, te toma las filas de cada rango/hoja, probaste?

 

si probé pero me sale error en la fila, dice que no admite esta propiedad.

h(i).Range(dato(j)).Copy h1.Range("A" & u)

'

también probé así persiste el error

 Sheets(h(i)).Range(dato(j)).Copy h1.Range("A" & u)

publicado
  • Autor
En 12/2/2019 at 21:15 , temp01 dijo:

hoja = Array("Hoja2", "Hoja3", "Hoja4")

dato = Array("A1:B5", "C1:D5", "H1:I5")

Lo que intento ahora es copiar un rango por hoja, en la macro actual lo hace 3 rangos por hoja la cual no deseo. Gracias

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.