Problema con buscador

Saludos a todos.
En la aplicación que intento crear, tengo una tabla y creando un form con un buscador selectivo según la columna en la que encuentre el dato, he puesto el siguiente código:
Private Sub CommandButton2_Click()
If TextBox1 = "" Then
MsgBox "Nada que buscar"
Exit Sub
Else
End If
Range("A1").Select
TextBox4 = Empty
TextBox5 = Empty
TextBox6 = Empty
        Dim n As Range
    Set n = Range("A1:A200").Find(What:=TextBox1)
            If n Is Nothing Then
            Else
           n.Select
    TextBox4 = ActiveCell
    ActiveCell.Offset(0, 1).Select
    TextBox5 = ActiveCell
    ActiveCell.Offset(0, 1).Select
    TextBox6 = ActiveCell
    Exit Sub
            End If
'busqueda 2
Range("b1").Select
        Dim n1 As Range
    Set n1 = Range("b1:b200").Find(What:=TextBox1)
            If n1 Is Nothing Then
            Else
           n1.Select
    TextBox5 = ActiveCell
    ActiveCell.Offset(0, 1).Select
    TextBox6 = ActiveCell
    ActiveCell.Offset(0, -2).Select
    TextBox4 = ActiveCell
            Exit Sub
            End If
'busqueda 3
Range("C1").Select
        Dim n2 As Range
    Set n2 = Range("C1:C200").Find(What:=TextBox1)
            If n2 Is Nothing Then
            Else
            n2.Select
    TextBox6 = ActiveCell
    ActiveCell.Offset(0, -1).Select
    TextBox5 = ActiveCell
    ActiveCell.Offset(0, -1).Select
    TextBox4 = ActiveCell
    Exit Sub
       End If
    If TextBox4 = "" Then
    MsgBox "No encontrado"
 End If
 End Sub
Lo cierto es que funciona, solo que si por ejemplo en textbox1 escribo "alu" y en la celda A23 ahí un registro que se llama "aluminio" me rellena con los datos de esa fila en lugar de indicarme que no se encuentra ningún registro llamado "alu"
Espero haberme explicado con claridad y que alguien pueda ayudarme a resolver el dilema
Desde ya muchas gracias a todos.

1 Respuesta

Respuesta
1
Ajustá la instrucción de búsqueda, agregando la opción de coincidencia total:
Set n = Range("A1:A200").Find(What:=TextBox1, Lookat:=xlWhole)

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas