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.

COPIAR COLUMNAS ESPECIFICAS DE UN LIBRO A OTRO

publicado

Buenas tardes,

por favor podrían ayudarme con la siguiente macro que no he podido lograr dar una solución.

Esta macro lo acabo de copiar de la web ya que tiene todo lo que necesito, sin embargo tiene un pequeño detalle lo cual requiero me puedan ayudar. La macro marcha bien cuando realiza la primera copia, sin embargo, cuando se importa una segunda información la macro no logra copiar los datos en la fila continua... por favor podrían ayudarme a corregir ese detalle.

 

Gracias.

Dim Q&

Set ws1 = ActiveSheet

On Error Resume Next
  ws2 = "Selecciona el libro a procesar."
  MsgBox ws2, vbOKOnly
  ws2 = Application.GetOpenFilename(Title:=ws2)
  If ws2 = False Then Exit Sub
On Error GoTo 0

Set ws2 = Workbooks.Open(ws2, ReadOnly:=True).Sheets(1)
If [c12] = "" Then
  MsgBox "Libro sin información."
  GoTo Fin
End If

ReDim Mat(1 To 4)

Q = Range([a6], Cells(Rows.Count, "c").End(xlUp)).Rows.Count

Mat(1) = Application.Transpose(ws2.[a6].Resize(Q))
Mat(2) = Application.Transpose(ws2.[c6].Resize(Q))
Mat(3) = Application.Transpose(ws2.[d6].Resize(Q))
Mat(4) = Application.Transpose(ws2.[g6].Resize(Q))

ws1.[b3].Resize(Q, UBound(Mat)) = Application.Transpose(Mat)


Fin:
ws2.Parent.Close False
ws1.[a4].CurrentRegion.Columns.AutoFit
End Sub

Featured Replies

publicado
Public Sub copiarWs()
Dim Q&

Set ws1 = ActiveSheet

On Error Resume Next
  ws2 = "Selecciona el libro a procesar."
  MsgBox ws2, vbOKOnly
  ws2 = Application.GetOpenFilename(Title:=ws2)
  If ws2 = False Then Exit Sub
On Error GoTo 0

Set ws2 = Workbooks.Open(ws2, ReadOnly:=True).Sheets(1)
If [c12] = "" Then
  MsgBox "Libro sin información."
  GoTo Fin
End If

ReDim Mat(1 To 4)

Q = Range([a6], Cells(Rows.Count, "c").End(xlUp)).Rows.Count

Mat(1) = Application.Transpose(ws2.[a6].Resize(Q))
Mat(2) = Application.Transpose(ws2.[c6].Resize(Q))
Mat(3) = Application.Transpose(ws2.[d6].Resize(Q))
Mat(4) = Application.Transpose(ws2.[g6].Resize(Q))

LastRow = ws1.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
ws1.Range("b" & LastRow).Resize(Q, UBound(Mat)) = Application.Transpose(Mat)
'ws1.[b3].Resize(Q, UBound(Mat)) = Application.Transpose(Mat)


Fin:
ws2.Parent.Close False
ws1.[a4].CurrentRegion.Columns.AutoFit
End Sub

Prueba con la modificación

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.