我有一个在执行期间创建文本框的 excel 用户窗体。代码如下;
Dim CompHandler() As New CCompHandler
Dim tb As MSForms.TextBox
Dim count As Integer
For i in Range(something)
If i = anotherthing Then
Set tb = UserForm1.Controls.Add("Forms.TextBox.1", "tb" & count)
With tb
.Width = iTbWidth
.Top = count * distance
.Left = iTbLeft
.Height = iTbHeight
.Value = Cells(row, column)
ReDim Preserve CompHandler(0 To count)
Set CompHandler(count).TextBoxGroup = tb
End With
count = count + 1
End If
Next i
我想将更改后的值写回相应的单元格。我已经能够在盒子发生变化时获得新值,并在 a 上使用此代码获得新值class called CCompHandler
:
Option Explicit
Public WithEvents TextBoxGroup As MSForms.TextBox
Private Sub TextBoxGroup_Change()
MsgBox TextBoxGroup
End Sub
所以..关于如何获得哪个文本框已更改的任何想法?或者也许有更好的方法来做到这一点?提前致谢