Supportnet / Forum / Tabellenkalkulation
Checkbox
Frage
Hallo zusammen,
Ich versuche eine Checkbox in Excel zu erstellen.
Mit der Steuerelement-Toolbox geht dies ja recht einfach.
Mit Checkbox meine ich das Kontrollfeld mit dem Häckchen.
Was passieren soll, ist folgendes:
Wenn Häckchen aktiv, dann A1=1, wenn Häckchen nicht aktiv, dann A1=0.
Das mit "Wenn aktiv, dann A1=1" geht mit dem Makro Code:
Private Sub CheckBox1_Click()
ActiveCell.FormularR1C1 = "1"
End Sub
ganz gut.
Wie bekomme ich es nun hin, dass wenn das Häckchen nicht aktiv ist die Zelle A1=0 wird?
Gruß
Roland
Antwort 1 von Guenter
Hallo,
so z.B.
Gruß
Günter
so z.B.
Option Explicit
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then [a1] = 1 Else [a1] = 0
End Sub
Gruß
Günter
Antwort 2 von piano
Hallo
Die Anweisung:
Private Sub CheckBox1_Click()
ActiveCell.FormularR1C1 = "1"
End Sub
kannst Du so nicht einsetzen:
Versuch folgendes
Die Anweisung:
Private Sub CheckBox1_Click()
ActiveCell.FormularR1C1 = "1"
End Sub
kannst Du so nicht einsetzen:
Versuch folgendes
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
ActiveCell.Value = 1
Else
ActiveCell.Value = 0
End If
End Sub
Antwort 3 von cmkatz
Hi,
versuchs mit diesem Code:
[Code]
Private Sub CheckBox1_Click()
ActiveCell.Select
With Range("A1")
If CheckBox1.Value = True Then
.Value = 1
Else
.Value = ""
End If
End With
End Sub
Gruß
cmkatz
versuchs mit diesem Code:
[Code]
Private Sub CheckBox1_Click()
ActiveCell.Select
With Range("A1")
If CheckBox1.Value = True Then
.Value = 1
Else
.Value = ""
End If
End With
End Sub
Gruß
cmkatz
Antwort 4 von balumba
Vielen Dank an Euch alle.
Es klappt wunderbar. Genau so wollte ich es.
Gruß
Balumba
Es klappt wunderbar. Genau so wollte ich es.
Gruß
Balumba

