Espacios vacíos y No limpia los valores EXCEL

Otra vez Dante.

Relacionado al tema anterior Búsqueda de datos VBA, a perfeccionar el código que me anexaste esta Genial pero me paso algo.

Te lo muestro con una imagen:

Bueno creo que una imagen habla más que palabras, a ver si me ayudas con ese detalle.

1 respuesta

Respuesta
1

Te anexo la macro actualizada.

Private Sub Worksheet_Change(ByVal Target As Range)
'Por.Dante Amor
    'If Target.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("A2:C10")) Is Nothing Then
        For Each t In Target
            existe = False
            If Cells(t.Row, "B") = "" Or t.Value = "" Or Cells(t.Row, "A") = "" Then
                Cells(t.Row, "D") = ""
            Else
                For Each h In Sheets
                    If h.Name <> ActiveSheet.Name Then
                        Set r = h.Columns("A")
                        Set b = r.Find(Cells(t.Row, "B"), lookat:=xlWhole)
                        If Not b Is Nothing Then
                            ncell = b.Address
                            Do
                                If Cells(t.Row, "A") = h.Cells(b.Row, "C") Then
                                    Cells(t.Row, "D") = h.Cells(b.Row, "B")
                                    existe = True
                                    Exit Do
                                End If
                                Set b = r.FindNext(b)
                            Loop While Not b Is Nothing And b.Address <> ncell
                        End If
                    End If
                Next
                '
                If existe = False Then
                    Cells(t.Row, "D") = ""
                    t.Select
                    MsgBox "Producto  No Encontrado", vbExclamation
                End If
            End If
        Next
    End If
End Sub

Dante, perfecto funciona a la perfección.

Te agradezco mucho por tu tiempo y por tu paciencia.

¡Gracias! 

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas