Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1280to1284
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
Inhaltsverzeichnis

Probleme mit VBA Code

Probleme mit VBA Code
17.10.2012 19:03:33
Luzi76
Hallo,
habe eine USerForm mit folgendem Code erstellt.
Option Explicit
Dim D As Object
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub ComboBox1_Change()
ComboBox2.List = D(ComboBox1.Value).Keys
ComboBox2.Value = Empty
ListBox1.Clear
End Sub
Private Sub ComboBox2_Change()
If ComboBox2.Value = Empty Then Exit Sub
ListBox1.List = D(ComboBox1.Value)(ComboBox2.Value).Keys
End Sub
Private Sub UserForm_Initialize()
Dim lz As Long, ar As Variant
Dim i As Long
With Tabelle8
lz = .Cells(.Rows.Count, 1).End(xlUp).Row
If lz >= 10 Then
ar = .Range("A10:N" & lz).Value
Else
MsgBox "Keine Daten!", vbExclamation, "Abbruch!"
End
End If
End With
Set D = CreateObject("scripting.dictionary")
For i = 1 To UBound(ar)
If Not D.Exists(ar(i, 3)) Then _
Set D(ar(i, 3)) = CreateObject("scripting.dictionary")
If Not D(ar(i, 3)).Exists(ar(i, 5)) Then _
Set D(ar(i, 3))(ar(i, 5)) = CreateObject("scripting.dictionary")
If Not D(ar(i, 3))(ar(i, 5)).Exists(ar(i, 13)) Then _
Set D(ar(i, 3))(ar(i, 5))(ar(i, 13)) = CreateObject("scripting.dictionary")
D(ar(i, 3))(ar(i, 5))(ar(i, 13)) = 0
Next
ComboBox1.List = D.Keys
End Sub
Leider wird mir aber nicht alles angezeigt was ich an Daten haben möchte.
wie müsste ich den Code umbauen damit die Daten aus Spalte A und D auch angezeigt werden.
Versuche die Mappe mal mit hochzuladen.
https://www.herber.de/bbs/user/82169.xlsm
Danke für eure Hilfe

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Probleme mit VBA Code
18.10.2012 11:00:05
Rudi
Hallo,
das ist Quatsch:
        If Not D.Exists(ar(i, 3)) Then _
Set D(ar(i, 3)) = CreateObject("scripting.dictionary")
If Not D(ar(i, 3)).Exists(ar(i, 5)) Then _
Set D(ar(i, 3))(ar(i, 5)) = CreateObject("scripting.dictionary")
If Not D(ar(i, 3))(ar(i, 5)).Exists(ar(i, 13)) Then _
Set D(ar(i, 3))(ar(i, 5))(ar(i, 13)) = CreateObject("scripting.dictionary")
weg damit!
D(ar(i, 3) & ar(i, 5) & ar(i, 13)) = 0
Gruß
Rudi

AW: Probleme mit VBA Code
18.10.2012 17:44:09
Luzi76
Also dein Ansatz funktioniert nicht.
Da wird die Lösung schon in die erste ComboBox geschrieben.

Anzeige
AW: Probleme mit VBA Code
18.10.2012 19:40:05
Luzi76
Habe es mit dem folgendem Code hinbekommen das alle Daten die ich brauche angezeigt werden.
Option Explicit
Dim D As Object
Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub ComboBox1_Change()
ComboBox2.List = D(ComboBox1.Value).Keys
ComboBox2.Value = Empty
ListBox1.Clear
End Sub

Private Sub ComboBox2_Change()
If ComboBox2.Value = Empty Then Exit Sub
ListBox1.List = D(ComboBox1.Value)(ComboBox2.Value).Keys
End Sub

Private Sub UserForm_Initialize()
Dim lz As Long, ar As Variant
Dim i As Long
With Tabelle8
lz = .Cells(.Rows.Count, 1).End(xlUp).Row
If lz >= 10 Then
ar = .Range("A10:N" & lz).Value
Else
MsgBox "Keine Daten!", vbExclamation, "Abbruch!"
End
End If
End With
Set D = CreateObject("scripting.dictionary")
For i = 1 To UBound(ar)
If Not D.Exists(ar(i, 3)) Then _
Set D(ar(i, 3)) = CreateObject("scripting.dictionary")
If Not D(ar(i, 3)).Exists(ar(i, 5)) Then _
Set D(ar(i, 3))(ar(i, 5)) = CreateObject("scripting.dictionary")
D(ar(i, 3))(ar(i, 5))(ar(i, 1)) = 0
D(ar(i, 3))(ar(i, 5))(ar(i, 4)) = 0
D(ar(i, 3))(ar(i, 5))(ar(i, 13)) = 0
Next
ComboBox1.List = D.Keys
End Sub
Nur leider wird das untereinander angezeigt. Das wird dann sehr unübersichtlich wenn mehrere Datensätze vorhanden sind.
Gibt es die Möglichkeit das die Daten nebeneinander angezeigt werden?
Und wenn mehrere Datensätze vorhanden sind dann die zusammenhängenden Datensätze untereinander.
Sprich: Früh 17.10.12 Luftleckage
Spät 17.10.12 Azo Störung
Und nicht wie jetzt: Früh
17.10.12
Luftleckage
Spät
17.10.12
Azo Störung
Falls jemand ne Idee hat, bitte melden.

Anzeige
AW: Probleme mit VBA Code
19.10.2012 14:57:14
Luzi76
Habe es nun hinbekommen, dass die Daten zwar noch untereinander angezeigt werden, aber zumindest wird zwischen den einzelnen Datensätzen eine Zeile frei gelassen.
Das nächste Problem welches jetzt auftaucht ist, das ab dem dritten Datensatz nurnoch das Datum angezeigt wird.
Hier mal die Datei
https://www.herber.de/bbs/user/82203.xlsm

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige