私はBPName2
とSPName2
という2つのテキストボックスを持つuserformを持っています。以下のコードのIf found=true then exit for
ステートメントの後。 2番目のテキストボックスに移動したいと思います。しかし、そうすることに問題があります。誰でもこれを行う方法についてのアイデアはありますか?1つのテキストボックスの終了イベントから他のテキストボックスへのカーソルのフォーカスを設定する方法
Private Sub txt_BPName2_Exit(ByVal Cancel As ReturnBoolean)
Dim Row As Integer
Row = ActiveCell.Row
Dim c As Range
Dim found As Boolean
found = False
For Each c In Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
If c.Value = txt_BPName2 Then MsgBox "Cell " & c.Address & " Base Product Found."
If c.Value = txt_BPName2 Then found = True
If found = True Then Exit For
Next
If found = False Then
'Cells(Row, 1).Value = txt_BPName2.Text
MsgBox ("Base Product not found")
'ActiveCell.Offset(1, 0).Select
Add_Inventory_SP.Hide
End If
Cancel = True
End Sub
このコード行の後に正確に何をしたいですか? –
'MsgBox'で行をコメントアウトします。それはあなたが望むことをしますか? –
'NextTextBoxName.SetFocus'に似ていますか?また、コードをより効率的に変更することもできます。 – PatricK