Macro copiar y pegar filas filtradas
Necesito copiar y pegar datos de una hoja con datos filtrados hacia otra hoja. Me explico, tengo la hoja "Report" en la cual filtro datos de la columna "X" mediante el CommandButton4. Necesito copiar y pegar las filas filtradas que tengan datos en las columnas B, C, D, E Y F hacia la hoja "Despacho".
Considerar que las macros funcionan cuando no uso filtros, pero cuando filtro ya no funciona.
Adjunto UserForm y Código fuente.

Private Sub CommandButton4_Click()
'Ingresar datos
pedido = TextBox9.value
If pedido = "" Then
MsgBox "Debes capturar un número de pedido"
TextBox9.SetFocus
Exit Sub
End If
If IsNumeric(pedido) Then pedido = Val(pedido)
Set h = Sheets("Report")
Set r = h.Columns("A")
Set b = r.Find(pedido, LookAt:=xlWhole)
If Not b Is Nothing Then
Celda = b.Address
Do
'detalle
If h.Cells(b.Row, "B") = "" Then
h.Cells(b.Row, "B") = ComboBox2.value 'Columna B Courier
h.Cells(b.Row, "C") = ComboBox3.value 'Columna C Placa
h.Cells(b.Row, "D") = TextBox8.value 'Columna D Nombre del Transportista
h.Cells(b.Row, "E") = TextBox9.value 'Columna E N° de Pedido
h.Cells(b.Row, "G") = TextBox10.value 'Columna G GR Hija
h.Cells(b.Row, "F") = Now 'Fecha y hora
TextBox7 = Sheets("Datos").Range("E2")
Else
MsgBox "Pedido ya existe"
TextBox9.value = ""
TextBox9.value = ""
TextBox10.value = ""
TextBox9.SetFocus
Exit Sub
End If
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> Celda
TextBox9.value = ""
TextBox9.value = ""
TextBox10.value = ""
TextBox9.SetFocus
Else
MsgBox "El pedido no existe"
TextBox9.value = ""
TextBox9.value = ""
TextBox10.value = ""
TextBox9.SetFocus
End If
With TextBox7
.Font.Size = 15
.TextAlign = fmTextAlignCenter
.AutoSize = True
End With
With TextBox2
.Font.Size = 15
.TextAlign = fmTextAlignCenter
.AutoSize = True
End With
UserForm3.Show
End Sub
1 respuesta
Respuesta de Programar Excel
-1