[算表] excel, vba, userform, textbox
軟體:
Excel
版本:
2003
Userform1 X
●OptionButton1 ●Optionbutton2
████████████████
如圖...
當我在下面的TextBox1中輸入資訊
最後鍵下 Enter後 達成我要的目標
但是附帶一個我不要的效果想要取消....
當我鍵下 Enter 後 它會自動轉移到 OptionButton1
導致我沒辦法直接重新輸入資訊
我的希望是 我只要一直重複 資訊-> Enter 資訊-> Enter ....
不需要 Enter 後重新點選 textbox1 或者按兩下 Tab
請問該怎樣設定選項?? 或者該怎樣寫??
新手摸黑亂試... 請各位先進幫幫忙 3Q
另外 謝謝之前 lantolerance 以及 Steven0422 兩位先進幫忙解惑
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.70.46.61
推
02/06 17:05, , 1F
02/06 17:05, 1F
→
02/06 18:35, , 2F
02/06 18:35, 2F
推
02/06 18:47, , 3F
02/06 18:47, 3F
Userform1
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = vbKeyReturn Then
If TextBox1.Value <> "" Then
If UserForm1.OptionButton1.Value = True Then
ActiveCell.Value = "type1"
Module1.type1
ElseIf UserForm1.OptionButton2.Value = True Then
ActiveCell.Value = "type2"
Module1.type2
Else
MsgBox "請選擇類別~"
End If
TextBox1.Value = ""
Else
MsgBox "請輸入內容"
End If
End If
End Sub
Module1
Sub type1()
ActiveCell.Offset(0, 1).Value = UserForm1.TextBox1.Value
ActiveCell.Offset(1, 0).Select
End Sub
---------------------------------------------------------
Sub type2()
ActiveCell.Offset(0, 2).Value = UserForm1.TextBox1.Value
ActiveCell.Offset(1, 0).Select
End Sub
我剛剛在想 textbox1.setfocus 的動作
似乎是在整個 Sub TextBox1_KeyDown~End sub之中
但是選擇位置的自動轉移 好像是在 Sub TextBox1_KeyDown~End sub之後??
※ 編輯: firelf 來自: 219.70.46.99 (02/06 19:37)
※ 編輯: firelf 來自: 219.70.46.99 (02/06 19:47)
※ 編輯: firelf 來自: 219.70.46.99 (02/06 19:50)
→
02/08 16:09, , 4F
02/08 16:09, 4F
→
02/08 16:10, , 5F
02/08 16:10, 5F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
Office 近期熱門文章
PTT數位生活區 即時熱門文章