返回列表 上一主題 發帖

焦點及控制權問題

本帖最後由 singo1232001 於 2023-7-24 02:19 編輯

回復 2# reangame

Public actRng
Private Sub CommandButton1_Click()
actRng.Value = "▲"
'actRng.Offset(0, 1).Select
'ThisWorkbook.ActiveSheet.Activate ' 將控制權轉移到目前工作表

unload me
'或者可以試試看UserForm1. Hide
End Sub


Private Sub UserForm_Activate()
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeName(ctrl) = "CommandButton" Then
ctrl.TabStop = False
End If
Next ctrl
End Sub

Private Sub CommandButton1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = vbKeyTab Then
Application.SendKeys "{TAB}"
KeyCode = 0
End If
End Sub
複製代碼

Sub showUF1()
    set actRng = ActiveCell
    UserForm1.Show 0 'modeless
End Sub

TOP

        靜思自在 : 虛空有盡.我願無窮,發願容易行願難。
返回列表 上一主題