ich bilde zur Laufzeit ein Button Array, das Problem ist das nur der letzte Button erkannt wird. Hier mein Code:
In ein Klassenmodul:
Option Explicit
Public WithEvents myCmd As MSForms.CommandButton
Dim Label16 As Object
Private Sub myCmd_Click()
'MsgBox (myCmd.Caption & " gedrückt")
UserForm1.Label16 = myCmd.Caption
End Sub
In Userform1:
Private Sub UserForm_Initialize()
Dim Obj As Object
Dim a As Integer
Dim i As Long
Dim myClass As cls_Test
Set myClass = New cls_Test
For i = 1 To 49
Set myClass.myCmd = Frame1.Controls.Add("Forms.CommandButton.1", "myCmd" & i, True)
With myClass.myCmd
' .Tag = i + 1
' .Caption = Sheets("Tabelle6").Range("A1" & i).Value
.Left = 0
.Height = 20
.Width = 55
.Top = i * 20 - 20
For Each Obj In Me.Frame1.Controls
If Obj.Name = "myCmd" & i Then
Obj.Caption = Sheets("Tabelle6").Range("A" & i).Value
End If
Next Obj
End With
Next i
myColl.Add myClass
With Frame1
'~~> This will create a vertical scrollbar
.ScrollBars = fmScrollBarsVertical
.ScrollHeight = .InsideHeight * 7.5 / 3 '~~> Change the values of 2 as Per your _
requirements
.ScrollWidth = .InsideWidth * 9
End With
End Sub
Kann mir bitte jemand helfen das alle Button angesprochen werden?Danke in Voraus
Antonio