ich möchte per Makro mehrere Gruppen von OptionButtons (Form Controls) erzeugen. Die Gruppen sollen unabhängig sein. Der letzte Teil klappt bisher nicht, obwohl ich extra ein Gruppenfeld um die Buttons lege. Stattdessen sind alle Gruppen miteinander verbunden.
Kann mir jemand sagen, was ich vergessen habe?
Vielen Dank
Martin
Mein Code ist wie folgt: (die Subroutine wird für jede Gruppe einmal aufgerufen)
Sub MakeOptionButtons(ByVal FrageNummer As Integer, ByVal ZeileStart As Integer, ByVal Choices _
_
As Integer)
Dim btn As OptionButton
Dim i As Long
Dim t, s As Range
Dim box As GroupBox
Set s = ActiveSheet.Range(Cells(ZeileStart + 2 + 1, 1), Cells(ZeileStart + 2 + Choices - 1, 1) _
_
)
For i = ZeileStart + 2 To ZeileStart + 2 + Choices - 1 Step 1
Set t = ActiveWorkbook.Sheets("Formular").Range(Cells(i, 1), Cells(i, 1))
Set btn = ActiveWorkbook.Sheets("Formular").OptionButtons.Add(t.Left + 20, t.Top, t.Width, _
_
t.Height)
With btn
'.OnAction = "btnS"
.Caption = ""
.name = "ButtonFrage" & FrageNummer & "_" & i - (ZeileStart + 2) + 1
.GroupName = "GruppenFeldFrage" & FrageNummer
If i = ZeileStart + 2 Then
.LinkedCell = "Formular!$I$" & i
End If
End With
Next i
Set box = ActiveWorkbook.Sheets("Formular").GroupBoxes.Add(s.Left, s.Top - 20, s.Width, s. _
Height + 20)
box.name = "GruppenFeldFrage" & FrageNummer
End Sub