VBA-ComboBox -> Hilfe!!!
Babak
Hallo,
ich bin gerade dabei, ein kleines Programm mit einer Userform in Excel zu erstellen.
In der Userform befindet sich eine ComboBox.
Diese ComboBox soll dazu dienen, dass das Programm bei Name 1 ("Tatjana") die Berechnungen in einem bestimmten Bereich in Excel kopiert, und bei Name 2 ("Sabrina") in einem anderen Bereich.
Zur Verdeutlichung hier ein Auszug aus meinem Programm (Link zur ganzen Datei s.o.):
If ComboBox1 = "Tatjana" Then
labpause.Caption = Format(pause, "0.00 Std.")
labarbeitszeit.Caption = Format(arbeitszeit, "0.00 Std.")
labüberstd.Caption = Format(überstd, "0.00 Std.")
With Worksheets("april")
.Cells(6 + reihe, 2).Value = komm
.Cells(6 + reihe, 3).Value = geh
.Cells(6 + reihe, 4).Value = anfang
.Cells(6 + reihe, 5).Value = ende
.Cells(6 + reihe, 6).Value = labarbeitszeit.Caption
.Cells(6 + reihe, 7).Value = labpause.Caption
.Cells(6 + reihe, 8).Value = labüberstd.Caption
End With
Else
If ComboBox1 = "sabrina" Then
labpause.Caption = Format(pause, "0.00 Std.")
labarbeitszeit.Caption = Format(arbeitszeit, "0.00 Std.")
labüberstd.Caption = Format(überstd, "0.00 Std.")
With Worksheets("april")
.Cells(6 + reihe2, 12).Value = komm
.Cells(6 + reihe2, 13).Value = geh
.Cells(6 + reihe2, 14).Value = anfang
.Cells(6 + reihe2, 15).Value = ende
.Cells(6 + reihe2, 16).Value = labarbeitszeit.Caption
.Cells(6 + reihe2, 17).Value = labpause.Caption
.Cells(6 + reihe2, 18).Value = labüberstd.Caption
End With
...
Nun mein Problem:
Was muss hinter ComboBox1 als Befehl bzw. Eigenschaft stehen, damit die If-Abfrage nach z.B. "Tatjana" erfolgen kann.
Ich habe schon versucht:
If ComboBox1 = "Tatjana" Then
If ComboBox1.value = "Tatjana" Then
If ComboBox1.caption = "Tatjana" Then...
Klappt alles nicht.
Wer kann mir helfen?
Vielen Dank und Gruß
Babak