|
可是当我输入不等于r1的时候,EXCEL直接就把VB编辑器弹出来了
如何才能实现当不等于前面B列(料号)的时候会弹出“输入错误”提示呢?
也就是当我输入表格里没有的料号时,怎样才能会弹出“输入错误”提示呢?
这个我怎么试都不成功,请高手赐教:
Private Sub CommandButton1_Click()
Dim pn$, sl$
pn = ComboBox1.Text
sl = TextBox2.Text
Set r1 = Sheet3.[b:b].Find(pn)
For i = 7 To 15
Me.ComboBox1 = Null
Me.TextBox2 = Null
Me.ComboBox1.SetFocus
If Sheet3.Cells(r1.Row, i) = "" Then Sheet3.Cells(r1.Row, i) = sl: Exit Sub
Next
End Sub
Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then CommandButton1_Click
End Sub
Private Sub UserForm_Initialize()
Dim Arr, i&, d, k
Arr = Sheet3.[a1].CurrentRegion
Set d = CreateObject("Scripting.Dictionary")
For i = 4 To UBound(Arr)
d(Arr(i, 2)) = ""
Next
k = d.keys
Me.ComboBox1.List = k
End Sub
示例0808.rar
(30.48 KB, 下载次数: 6)
|
|