Comparar 2 hojas y copiar datos excel vba
[Hola Dante buenas tardes
Elaboré ésta macro para comparar 2 hojas pero sale faltando datos de la ultima comparación

Aquí la macro
Sub Comparar_copia()
Set h1 = Sheets("NOMBRES")
Set h2 = Sheets("TABLA TIPOS")
'
u = h1.Range("B" & Rows.Count).End(xlUp).Row
'
h1.Range("E2:F" & Rows.Count).ClearContents
ant = h1.Cells(u, "B")
For i = u To 2 Step -1
'
Set r = h2.Columns("A")
Set b = r.Find(h1.Cells(i, "B"), lookat:=xlWhole)
If Not b Is Nothing Then
f = b.Row
If h1.Cells(i, "B") <> ant Then
h1.Cells(i, "E") = h2.Cells(f, "B")
h1.Cells(i, "F") = h2.Cells(f, "C")
End If
End If
ant = h1.Cells(i, "B")
Next i
'
MsgBox "Fin"
End Sub
1 respuesta
Respuesta de Dante Amor
1