作者:乔山办公网日期:
返回目录:excel表格制作
建议插入一知个按钮控件,将Default属性设道置:True (即按回车触发以下代回码)
输入答以下代码:
Private Sub CommandButton1_Click()
Dim a, i
a = TextBox1.Text
For i = 1 To Range("A" & Cells.Rows.Count).End(3).Row
If Format(Cells(i, 1), "0") = a Then
MsgBox "OK"
Exit For
ElseIf i = Range("A" & Cells.Rows.Count).End(3).Row Then
MsgBox "NG"
End If
Next i
With TextBox1
.SelStart = 0
.SelLength = Len(TextBox1.Text)
.SetFocus
End With
End Sub