Anzeige
Archiv - Navigation
804to808
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
804to808
804to808
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Statt Textbox Combobox

Statt Textbox Combobox
04.10.2006 13:33:49
Bernd
Hallo,
ich möchte gerne in meinem Userform mein bestehende Textbox durch eine Combobox ersetzen, wo nur "Gruppe A" oder "Gruppe B" zur Auswahl steht.
Was muss ich dafür genau an meinem Code ändern?
Gruss
Bernd

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Statt Textbox Combobox
04.10.2006 15:15:04
tina
hi Bernd,
versuch es mal damit:

Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Gruppe A"
.AddItem "Gruppe B"
End With
End Sub

Rückmeldung wäre nett
LG Tin@
AW: Statt Textbox Combobox
04.10.2006 15:40:48
Bernd
Hallo Tina,
hmm, das hilft mir nun leider nicht so weiter, wie erhofft.
Mein kompletter Userform-Code sieht so aus:

Private Sub ComboBox1_Click()
If ComboBox1.ListIndex <> 0 Then
TextBox1 = Cells(ComboBox1.ListIndex + 1, 1)
TextBox2 = Cells(ComboBox1.ListIndex + 1, 2)
TextBox3 = Cells(ComboBox1.ListIndex + 1, 3)
TextBox4 = Cells(ComboBox1.ListIndex + 1, 4)
TextBox5 = Cells(ComboBox1.ListIndex + 1, 5)
TextBox6 = Cells(ComboBox1.ListIndex + 1, 6)
Else
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
End If
End Sub


Private Sub CommandButton1_Click()
' Fragt nach, ob Datensatz wirklich gelöscht werden soll
If MsgBox("Datensatz wirklich löschen?", vbQuestion + vbYesNo, _
" Datensatz löschen") = vbNo Then Exit Sub
If ComboBox1.ListIndex > 0 Then
Rows(ComboBox1.ListIndex + 1).Delete
UserForm_Initialize
End If
End Sub


Private Sub CommandButton2_Click()
'Überprüft, ob in Textfeld 5 ein Datum
If IsDate(TextBox5) = False Then
MsgBox "Fehler: Datumsformat fehlerhaft."
Exit Sub
End If
'Überprüft, ob in Textfeld 6 ein Datum
If IsDate(TextBox5) = False Then
MsgBox "Fehler: Datumsformat fehlerhaft."
Exit Sub
End If
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
xZeile = [A65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 1) = TextBox1
Cells(xZeile, 2) = TextBox2
Cells(xZeile, 3) = TextBox3
Cells(xZeile, 4) = TextBox4
Cells(xZeile, 5) = TextBox5
Cells(xZeile, 6) = TextBox6
Columns("A:F").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub


Private Sub CommandButton3_Click()
'Beendet das Userform
Unload Me
End Sub


Private Sub UserForm_Initialize()
Dim aRow As Long, i As Long
Application.EnableEvents = False
ComboBox1.Clear
aRow = [A65536].End(xlUp).Row
ComboBox1.AddItem "neuen Datensatz hinzufügen"
For i = 2 To aRow
ComboBox1.AddItem Cells(i, 1) & " " & Cells(i, 2) & ", " & Cells(i, 5) & " - " & Cells(i, 6) & " [" & Cells(i, 3) & "]"
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub

Ich möchte nun statt Textfeld5 eine weitere Combobox (nr. 2) einfügen. Was muss ich dafür alles ändern?
Gruss & Danke
bernd
Anzeige
AW: Statt Textbox Combobox
04.10.2006 17:39:14
Bernd
@Tina
So, habe es mit ein bisschen probieren hinbekommen. Habe einfach überall da, wo Textbox4 stand, ComboBox 2 hingesetzt, und dan nur deinen obigen Code noch hinzugefügt.
Dank dir.
Gruss
Bernd

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige