Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
24.04.2024 17:19:09
Anzeige
Archiv - Navigation
1076to1080
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

Textfeld befüllen

Textfeld befüllen
18.05.2009 21:29:41
Marc
Hallo,
habe folgenden Code.

Private Sub txtValue_Change()
Dim arr() As Variant
Dim iRow As Integer, iCol As Integer, iCounter As Integer
If txtValue.TextLength = 9 Then
iRow = 2
Do Until IsEmpty(Cells(iRow, 1))
If Cells(iRow, 1) = txtValue.Text Then
iCounter = iCounter + 1
ReDim Preserve arr(2 To 4, 1 To iCounter)
For iCol = 2 To 4
arr(iCol, iCounter) = Cells(iRow, iCol).Value
Next iCol
End If
iRow = iRow + 1
Loop
lstValues.Column = arr
End If
End Sub


Wie bekomme ich es hin, dass mir alle Einträge ab Zeile 2 bis letztgefüllte Zeile in Spalte A in dem Feld angezeigt werden bzw. ich bin mit einem Pfeil auswählen kann?
Gruß
Marc

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Textfeld befüllen
20.05.2009 12:14:01
fcs
Hallo Marc,
unter Eigenschaften der Listbox muss du "ColumnCount" auf 3 setzen.
Die Prozedur dann z.B. wie folgt anpassen. Ich hab's in einem Userform probiert.
Gruß
Franz

Private Sub CB_Ok_Click()
'Command-Buton zur Anzeige des in der Liste ausgewählten Wertes
With Me.lstValues
MsgBox "Listenauswahl: " & .Value & vbLf _
& "Spalte 2:  " & .List(.ListIndex, 1) & vbLf _
& "Spalte 3:  " & .List(.ListIndex, 2)
End With
End Sub
Private Sub txtValue_Change()
Dim arr() As Variant
Dim iRow As Integer, iCol As Integer, iCounter As Integer
If txtValue.TextLength = 9 Then
iRow = 2
Do Until IsEmpty(Cells(iRow, 1))
If Cells(iRow, 1) = txtValue.Text Then
iCounter = iCounter + 1
ReDim Preserve arr(2 To 4, 1 To iCounter)
For iCol = 2 To 4
arr(iCol, iCounter) = Cells(iRow, iCol).Value
Next iCol
End If
iRow = iRow + 1
Loop
If iCounter > 0 Then
lstValues.List = Application.WorksheetFunction.Transpose(arr)
'        lstValues.Column = arr
End If
End If
End Sub


Anzeige
AW: Textfeld befüllen
20.05.2009 16:07:50
Marc
Hallo Franz,
habe diese Lösung gefunden. Es scheint zu funzen, hoffe mal, dass das auch wirklich richtig funzt.

Private Sub UserForm_Initialize()
Dim i As Integer
Sheets("Tabelle1").Range("A2:A100").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
With frmGrepValues1.ComboBox1
For i = 2 To Worksheets("Tabelle1").UsedRange.Rows.Count
If Worksheets("Tabelle1").Cells(i, 1).Value  _
Worksheets("Tabelle1").Cells(i + 1, 1).Value Then _
.AddItem Cells(i, 1).Value
Next i
End With
End Sub



Private Sub combobox1_Change()
Dim arr() As Variant
Dim iRow As Integer, iCol As Integer, iCounter As Integer
If ComboBox1.TextLength = 4 Then
iRow = 2
Do Until IsEmpty(Cells(iRow, 1))
If Cells(iRow, 1) = ComboBox1.Text Then
iCounter = iCounter + 1
ReDim Preserve arr(1 To 4, 1 To iCounter)
For iCol = 1 To 4
arr(iCol, iCounter) = Cells(iRow, iCol).Value
Next iCol
End If
iRow = iRow + 1
Loop
lstValues.Column = arr
End If
End Sub


Auf alle Fälle danke für Deine Mühe und Hilfe!
Gruß
Marc

Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige