Anzeige
Archiv - Navigation
244to248
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
244to248
244to248
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Inhalt von ComboBoxen prüfen

Inhalt von ComboBoxen prüfen
15.04.2003 21:09:04
Matthias H.
Hallo,

mit folgender Funktion möchte ich in einer UserForm prüfen, ob der Inhalt der Comboboxen 1 bis 10 identisch mit einer Zelle einer gegebenen Range (P2:P5) ist. Wenn das nicht der Fall ist, soll der Text in der jeweiligen Combobox gelöscht werden:

Dim y As Integer, z As Integer
For y = 1 To 10
For z = 2 To 5
If Controls("Combobox" & y).Text = Cells(z, 16) Then
Controls("Combobox" & y).Text = Controls("Combobox" & y).Text
Else
Controls("ComboBox" & z).Text = ""
End If
Next
Next

Leider klappt das nicht so richtig. Was mache ich falsch?

Gruß
Matthias

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

Betreff
Datum
Anwender
Anzeige
Re: Inhalt von ComboBoxen prüfen
15.04.2003 23:10:37
Ramses

Hallo,

was klappt denn nicht ?

Gruss Rainer

Re: Inhalt von ComboBoxen prüfen
15.04.2003 23:12:26
Ric

Muss das z in 'Controls("ComboBox" & z).Text = ""' nicht ein x sein?
Gruss
Ric


geht nur manchmal
16.04.2003 08:42:09
Matthias H.

Hallo Rainer,

Entweder wird der Text in Comboboxen gelöscht, obwohl er in der Range (P2:P5) vorkommt, oder es tritt das Gegenteil ein, d.h. der falsche Text bleibt stehen.
Ich habe die Schleife nochmal weggelassen, aber selbst dann funktioniert es nur sporadisch:

If ComboBox1.Text = Cells(2, 16) Or ComboBox1.Text = Cells(3, 16) Or ComboBox1.Text = Cells(4, 16) Or ComboBox1.Text = Cells(5, 16) Then
ComboBox1.Text = ComboBox1.Text
Else
ComboBox1.Text = "ändern"
End If


If ComboBox2.Text = Cells(2, 16) Or ComboBox1.Text = Cells(3, 16) Or ComboBox1.Text = Cells(4, 16) Or ComboBox1.Text = Cells(5, 16) Then
ComboBox2.Text = ComboBox2.Text
Else
ComboBox2.Text = "ändern"
End If

If ComboBox3.Text = Cells(2, 16) Or ComboBox1.Text = Cells(3, 16) Or ComboBox1.Text = Cells(4, 16) Or ComboBox1.Text = Cells(5, 16) Then
ComboBox3.Text = ComboBox3.Text
Else
ComboBox3.Text = "ändern"
End If

If ComboBox4.Text = Cells(2, 16) Or ComboBox1.Text = Cells(3, 16) Or ComboBox1.Text = Cells(4, 16) Or ComboBox1.Text = Cells(5, 16) Then
ComboBox4.Text = ComboBox4.Text
Else
ComboBox4.Text = "ändern"
End If

...


Anzeige

299 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige