我希望这可以相当容易地回答。我有一个userform
,textbox
和command button
用作密码输入。查找并选择范围内的值
我想知道的是,我可以将wrap/edit
下面的宏转换成if
语句,该语句检查输入到textbox1
中的值是否在第一个范围内?如果列表中的值为IS则运行下面的宏,如果不是则返回错误消息。这将提交command button
。
Dim FindString As String
Dim Rng As Range
FindString = Password.TextBox1.Value
If Trim(FindString) <> "" Then
With Sheets("CC Number").Range("A:A")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
Application.Goto Rng, True
Else
End If
End With
End If
你怎么会知道'textbox1'的输入已经进入?如果密码总是有一定的长度,但用户可以通过按提交按钮来告诉密码确实输入了密码,这可能会起作用。一种可能性是禁用提交按钮,并检查输入为密码的字符是否在您的范围内('KeyUp'来触发搜索)。如果密码在您的列表中,请启用提交按钮。 – CMArg