我想在Sheet2的B列中搜索TextBox1的值。我在另一个用户窗体上具有相同的代码,并且可以正常工作,但是我制作了一个新的用户窗体,但无法正常工作。好像Findleg没有带来任何好处。
任何人都可以发现错误吗?
Private Sub TextBox1_Enter()
Dim Findleg As Range
Dim leg As String
'Encontrar el legajo en la lista
leg = TextBox1.Value
Set Findleg = Hoja2.Range("B:B").Find(What:=leg, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
If Findleg Is Nothing Then
MsgBox "No se encuentra el legajo"
'Deja las casillas vacias cuando termina
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
Exit Sub
Else
TextBox2.Value = Findleg.Offset(0, 1)
TextBox3.Value = Findleg.Offset(0, 2)
End If
End Sub
我发现了问题,我已经隐藏了一个按钮来检查该值,而不是一个文本框。