4.5k Aufrufe
Gefragt in Tabellenkalkulation von
Hallo zusammen,

habe hier folgendes Problem:
Ich möchte in eine variable Anzahl von Zeilen Checkboxen einfügen. Diese sollten zentral positioniert sein innerhalb einer Zelle und jeweils einen eigenen Namen haben entsprechend ihrer Zeile (z. B. Checkbox in Zeile 45 sollte "CheckBox(45)" heißen.)

Hab folgendes produziert, aber leider läuft nix!

Dim CheckBox() As OLEObject
With Worksheets("Output").Cells(z, x)
Set CheckBox(z) = ActiveSheet.OLEObjects.Add _
(ClassType:="Forms.CheckBox.1", _
Left:=Worksheets("Output").Cells(z, x).Left, _
Top:=Worksheets("Output").Cells(z, x).Top, _
Width:=Worksheets("Output").Cells(z, x).Width, _
Height:=Worksheets("Output").Cells(z, x).Height)
With CheckBox(z).Object
.Caption = " "
.BackColor = vbWhite
End With
End With


Da ich wirklich nicht mehr weiter weiss und auch nichts adequates finden konnte, schreibe ich nun diesen Post.
Vielen Dank für alle Antworten!

1 Antwort

0 Punkte
Beantwortet von beverly Experte (3.5k Punkte)
Hi Philipp,
Dim ooCheckBox As OLEObject
With Worksheets("Output").Cells(z, x)
Set ooCheckBox = ActiveSheet.OLEObjects.Add _
(ClassType:="Forms.CheckBox.1", _
Left:=Worksheets("Output").Cells(z, x).Left, _
Top:=Worksheets("Output").Cells(z, x).Top, _
Width:=Worksheets("Output").Cells(z, x).Width, _
Height:=Worksheets("Output").Cells(z, x).Height)
With ooCheckBox.Object
.Caption = " "
.BackColor = vbWhite
End With
ooCheckBox.Name = "CheckBox" & z
End With


Bis später,
Karin
...