H o l a:
Te anexo la macro para los eventos de la hoja1
Private Sub Worksheet_Change(ByVal Target As Range)
'Por.Dante Amor
If Target.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
If Target.Address(False, False) = "W7" Then
Set h1 = Sheets("Hoja1")
Set h2 = Sheets("Hoja2")
Set h3 = Sheets("formato")
'
u = h1.Range("V" & Rows.Count).End(xlUp).Row
If u < 12 Then u = 12
f = 12
existe = False
h1.Range("V12:AB" & u).Clear
'
Set r = h2.Columns("A")
Set b = r.Find(Target, lookat:=xlWhole)
If Not b Is Nothing Then
ncell = b.Address
Do
'
For i = 5 To h1.Range("B" & Rows.Count).End(xlUp).Row
If h1.Cells(i, "B") = h2.Cells(b.Row, "B") Then
h3.Range("A2:G2").Copy h1.Cells(f, "V")
h1.Range(h1.Cells(i, "B"), h1.Cells(i, "H")).Copy
h1.Cells(f, "V").PasteSpecial xlValues
f = f + 1
existe = True
Exit For
End If
Next
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
'
If existe Then
h3.Range("A3:G3").Copy h1.Cells(f, "V")
With h1.Range("W" & f & ":AB" & f)
.Formula = "=SUM(W12:W" & f - 1 & ")"
End With
Else
MsgBox "El Vendedor no tiene rutas en Hoja1", vbExclamation, "CONSULTA RUTAS DE VENDEDOR"
End If
Else
MsgBox "El Número de Vendedor no Existe en Hoja2", vbExclamation, "CONSULTA RUTAS DE VENDEDOR"
End If
End If
Application.ScreenUpdating = True
End Sub
‘
S a l u d o s . D a n t e A m o r. Recuerda valorar la respuesta. G r a c i a s