Te anexo la macro
Sub Buscar_Coincidencias()
'Por.Dante Amor
Application.ScreenUpdating = False
Set h1 = Sheets("Data_Real")
Set h2 = Sheets("temp")
Set h3 = Sheets("resultado")
h2.Cells.Clear
h3.Cells.Clear
If h1.AutoFilterMode Then h1.AutoFilterMode = False
'
u1 = h1.Range("C" & Rows.Count).End(xlUp).Row
h1.Range("A1:L" & u1).AutoFilter Field:=3, Criteria1:="=*NCI*"
u1 = h1.Range("C" & Rows.Count).End(xlUp).Row
h1.Range("A1:L" & u1).Copy h2.Range("A1")
u2 = h2.Range("C" & Rows.Count).End(xlUp).Row
If h1.AutoFilterMode Then h1.AutoFilterMode = False
h2.Columns("C").Copy h2.Columns("M")
Call Reemplazar(h2)
'
h1.Rows(1).Copy h3.Rows(1)
j = 2
For i = 2 To u2
docu = h2.Cells(i, "C")
If InStr(1, docu, "-") > 0 Then
datos = Split(docu, "-")
If Len(datos(0)) > Len(datos(1)) Then
docu = WorksheetFunction.Trim(datos(0))
Else
docu = WorksheetFunction.Trim(datos(1))
End If
End If
existe = False
cargo = Abs(h2.Cells(i, "J"))
Set r = h1.Columns("C")
Set b = r.Find(docu, LookAt:=xlPart)
If Not b Is Nothing Then
celda = b.Address
Do
'detalle
abono = Abs(h1.Cells(b.Row, "K"))
If abono = cargo Then
h1.Rows(b.Row).Copy h3.Rows(j + 1)
h2.Rows(i).Copy h3.Rows(j)
h3.Cells(j, "C") = h3.Cells(j, "M")
j = j + 2
existe = True
Exit Do
End If
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> celda
End If
If existe = False Then
h2.Cells(i, "C").Interior.ColorIndex = 6
End If
Next
Application.ScreenUpdating = True
MsgBox "Proceso de comparación terminado", vbInformation
End Sub
'
Sub Reemplazar(h2)
h2.Columns("C:C").Replace What:="NCI-", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
h2.Columns("C:C").Replace What:="NCI ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
h2.Columns("C:C").Replace What:="NCI", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
h2.Columns("C:C").Replace What:="NC", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
h2.Columns("C:C").Replace What:="N", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
.
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias
.
Avísame cualquier duda
.