Thema Datum  Von Nutzer Rating
Antwort
07.03.2011 14:42:26 daniel001
NotSolved
07.03.2011 14:43:42 daniel001
NotSolved
07.03.2011 14:50:01 Gast42947
NotSolved
07.03.2011 15:13:48 Severus
NotSolved
07.03.2011 15:26:32 daniel001
NotSolved
07.03.2011 16:03:16 daniel001
NotSolved
07.03.2011 16:25:01 Severus
NotSolved
07.03.2011 16:41:01 Gast3944
NotSolved
07.03.2011 16:44:12 Daniel001
NotSolved
07.03.2011 16:55:20 daniel001
NotSolved
07.03.2011 17:58:32 Severus
NotSolved
08.03.2011 10:27:52 Gast27201
NotSolved
08.03.2011 12:22:28 Severus
NotSolved
Blau Laufzeitfehler -2147024809 (80070057)
08.03.2011 12:36:32 Gast14356
NotSolved
08.03.2011 13:32:55 Severus
NotSolved
08.03.2011 14:05:04 Severus
NotSolved
08.03.2011 14:12:11 Severus
NotSolved
08.03.2011 15:28:56 Gast79202
NotSolved
15.03.2011 16:37:22 daniel001
NotSolved
15.03.2011 17:33:36 Severus
Solved
16.03.2011 10:27:45 daniel001
NotSolved

Ansicht des Beitrags:
Von:
Gast14356
Datum:
08.03.2011 12:36:32
Views:
1416
Rating: Antwort:
  Ja
Thema:
Laufzeitfehler -2147024809 (80070057)

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Option Explicit
  
Dim lngInfoZeile As Long
Dim rngBereich As Range
Private Sub UserForm_Initialize()
    Dim i As Integer
    With Worksheets("Tabelle1")
        Set rngBereich = .Range("A2:D" & .Range("A" & .Rows.Count).End(xlUp).Row)
    End With
End Sub
  
Private Sub CommandButton1_Click()
    Unload Me
End Sub
Private Sub ComboBox1_Enter()
    ComboBox1.List = SVERWEISSPECIAL(rngBereich, 1)
End Sub
Private Sub ComboBox1_Change()
TextBox1.Text = TB_fuellen
End Sub
Private Sub ComboBox2_Enter()
    On Error Resume Next
    ComboBox2.List = SVERWEISSPECIAL(rngBereich, 2, Array(1), Array(ComboBox1))
    On Error GoTo 0
End Sub
Private Sub ComboBox2_Change()
    TextBox1.Text = TB_fuellen
End Sub
  
  
  
  
Private Function TB_fuellen() As String
Dim ctrCTR As Control
Dim ctrCB As ComboBox
Dim strTBText As String
Dim ctrSpalte As Long
TB_fuellen = ""
'Spaltennummer mit dem gewünschten Eintrag. Bei einspaltiger ComboBox ist die Spaltennummer=0
ctrSpalte = 1
 For Each ctrCTR In Me.Controls 
        If InStr(1, UCase(ctrCTR.Name), "COMBOBOX", vbBinaryCompare) <> 0 Then
            Set ctrCB = ctrCTR
            If ctrCB.ColumnCount = 1 Then
                        ctrSpalte = 0
            Else
                        ctrSpalte = 1
            End If
            strTBText = strTBText & ctrCB.List(ctrCB.ListIndex, ctrSpalte) 
            Set ctrCB = Nothing
        End If
Next
    For Each ctrCTR In Me.Controls
        If InStr(1, UCase(ctrCTR.Name), "COMBOBOX", vbBinaryCompare) <> 0 Then
            Set ctrCB = ctrCTR
            strTBText = strTBText & ctrCB.List(ctrCB.ListIndex, ctrSpalte)
            Set ctrCB = Nothing
        End If
Next
TB_fuellen = strTBText
End Function
  
  
Private Function SVERWEISSPECIAL(Matrix As Range, AusgabeSpalte As Integer, Optional KriteriumSpalten As Variant = 0, Optional KriteriumWerte As Variant = 0) As Variant
Dim arr As Variant
Dim DicOut As Object
Dim strVgl1 As String
Dim strVgl2 As String
  
Dim i As Long
Dim k As Long
  
On Error GoTo Ende
Set DicOut = CreateObject("Scripting.Dictionary")
arr = Matrix.Value
      
If Not IsArray(KriteriumSpalten) Or Not IsArray(KriteriumWerte) Then
    For i = 1 To UBound(arr)
        If arr(i, AusgabeSpalte) <> "" Then _
        DicOut(arr(i, AusgabeSpalte)) = ""
    Next
Else
    For k = 0 To UBound(KriteriumWerte)
        strVgl1 = strVgl1 & "'#$#" & KriteriumWerte(k)
    Next
    For i = 1 To UBound(arr)
        strVgl2 = ""
        For k = 0 To UBound(KriteriumSpalten)
            strVgl2 = strVgl2 & "'#$#" & arr(i, KriteriumSpalten(k))
        Next
        If arr(i, AusgabeSpalte) <> "" Then _
        If strVgl1 = strVgl2 Then _
        DicOut(arr(i, AusgabeSpalte)) = ""
    Next
End If
If DicOut.Count > 0 Then
arr = DicOut.Keys
QSort arr, LBound(arr), UBound(arr)
SVERWEISSPECIAL = arr
End If
Exit Function
Ende:
    SVERWEISSPECIAL = ""
End Function
  
Sub QSort(ByRef arr, low, hi)
Dim i, j, p
While low < hi
   p = arr(hi)
   i = low - 1
   For j = low To hi - 1
    If arr(j) <= p Then
     i = i + 1
     Swap arr, i, j
    End If
   Next
   Swap arr, i + 1, j
   QSort arr, low, i
   low = i + 2
Wend
End Sub
Sub Swap(ByRef arr, first, second)
Dim t
t = arr(first)
arr(first) = arr(second)
arr(second) = t
End Sub

So sieht mein Code nun aus. Auf der UserForm sind zwei KomboBoxen und eine Textbox. Die Exceltabelle ist so aufgebaut:

A        B        C         D
a                   b
54     54       Typ1   T1
54     54       Typ2   T2
54     54       Typ3   T3

56     56       Typ1   T1
56     56       Typ4   T4

BoundColumn = 1
ColumnCount = 1

Gut: Die Abhängigkeit von der ersten KomboBox ist immer noch gegeben.
Gut: Ich erhalte keinen Laufzeitfehler
Suboptimal: Die Ausgabe in der Textbox lautet nun 54Typ154Typ1...Es soll ja am Besten 54-T1 sein.  (Bzw das ist das, um was ich benötige)

 

Daniel

 


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
07.03.2011 14:42:26 daniel001
NotSolved
07.03.2011 14:43:42 daniel001
NotSolved
07.03.2011 14:50:01 Gast42947
NotSolved
07.03.2011 15:13:48 Severus
NotSolved
07.03.2011 15:26:32 daniel001
NotSolved
07.03.2011 16:03:16 daniel001
NotSolved
07.03.2011 16:25:01 Severus
NotSolved
07.03.2011 16:41:01 Gast3944
NotSolved
07.03.2011 16:44:12 Daniel001
NotSolved
07.03.2011 16:55:20 daniel001
NotSolved
07.03.2011 17:58:32 Severus
NotSolved
08.03.2011 10:27:52 Gast27201
NotSolved
08.03.2011 12:22:28 Severus
NotSolved
Blau Laufzeitfehler -2147024809 (80070057)
08.03.2011 12:36:32 Gast14356
NotSolved
08.03.2011 13:32:55 Severus
NotSolved
08.03.2011 14:05:04 Severus
NotSolved
08.03.2011 14:12:11 Severus
NotSolved
08.03.2011 15:28:56 Gast79202
NotSolved
15.03.2011 16:37:22 daniel001
NotSolved
15.03.2011 17:33:36 Severus
Solved
16.03.2011 10:27:45 daniel001
NotSolved