H o l a:
Te anexo la macro para los eventos de tu hoja
Private Sub Worksheet_Change(ByVal Target As Range)
'Por.Dante Amor
If Target.Address(False, False) <> "B1" Then Exit Sub
Set h1 = Sheets("Cuadro de pendiente")
Set h2 = Sheets("Status")
h1.UsedRange.Offset(4, 0).ClearContents
'
If h1.Range("B1") = "" Then Exit Sub
h1.[B2] = ""
j = 5
n = 1
'
Application.ScreenUpdating = False
Set r = h2.Columns("A")
Set b = r.Find(h1.Range("B1"), lookat:=xlWhole)
If Not b Is Nothing Then
ncell = b.Address
Do
ini = Array("B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P")
fin = Array("A", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "O", "P", "P", "Q")
For i = LBound(ini) To UBound(ini)
h1.Cells(j, ini(i)) = h2.Cells(b.Row, fin(i))
Next
'
h1.Cells(j, "A") = n
h1.Cells(j, "B") = h1.Cells(j, "B") & n
h1.Cells(j, "O") = h1.Cells(j, "N") - Date
j = j + 1
n = n + 1
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
h1.[B2] = n - 1
Else
MsgBox "El código de proveedor no existe", vbExclamation, "CUADRO DE CLIENTES"
Exit Sub
End If
Application.ScreenUpdating = True
MsgBox "Terminado", vbInformation, "CUADRO DE PENDIENTES"
End Sub
Sigue las Instrucciones para poner la macro en los eventos de worksheet
- Abre tu libro de excel
- Para abrir Vba-macros y poder pegar la macro, Presiona Alt + F11
- Del lado izquierdo dice: VBAProject, abajo dale doble click a worksheet(tu hoja)
- Del lado derecho copia la macro