Private Sub CommandButton1_Click()
Dim str As String
str = UserForm1.TextBox1.Text
Worksheets("资料").Activate
If str <> "" Then
If Range("a:a").Find(str) Is Nothing Then
MsgBox "对不起,查无此人!!!" ': Exit Sub '程序终止
UserForm1.TextBox1.Text = ""
Else
UserForm1.TextBox2.Text = Application.VLookup(str, Range("A:D"), 2, 0)
UserForm1.TextBox3.Text = Application.VLookup(str, Range("A:D"), 3, 0)
UserForm1.TextBox4.Text = Application.VLookup(str, Range("A:D"), 4, 0)
End If
Else
MsgBox "对不起,姓名不能为空!!!": Exit Sub '程序终止
End If
End Sub