0
我正在嘗試添加多個旋轉按鈕,並將它們中的每個按鈕鏈接到具有分配給它們的一些值的不同組單元格。我已經嘗試添加控件並使用類模塊向他們添加事件處理程序過程,但無濟於事。任何幫助,將不勝感激。將多個動態控件添加到用戶窗體併爲其分配不同的事件處理程序
Dim spinArray() As New Class1
Private Sub UserForm_Initialize()
Dim i As Long
Dim quantspin As MSForms.SpinButton
subassy_break.Height = pnum1 * 70
subassy_break.Width = 500
With Label_Var
.Top = 15
.Left = subassy_break.Width - (Label_Var.Width + 15)
.Caption = msg
.AutoSize = True
.Font.Bold = True
End With
With UserForm
For i = 1 To pnum1
Set quantspin = Me.Controls.Add("Forms.spinbutton.1", "Quantity_Count_" & i)
With quantspin
.Min = 0
.SmallChange = 1
.Max = 1
.Left = 200
.Top = subassy_break.height- pnum1*20
End With
Next i
End With
End Sub
也是我添加了一些新的類模塊
Public WithEvents spinevents As MSForms.SpinButton
Private Sub spinevents_change()
For i = 1 To pnum1
Cells(userow + i, usecol).Value = spinevents.Value
Next i
End Sub
歡迎來到Stackoverflow。你可以粘貼一張你的'Userform'圖片,這樣我們就可以看到你的意圖了 –