Re: Suchen Ergebnisse in mehrspaltiger Litbox
19.06.2003 00:52:22
L.Vira
Da nähere Angaben über die Struktur der Datenbank fehlen, bin
ich davon ausgegangen, das die Daten in A1:E65536 stehen und
keine Überschriften haben.
''Erforderliche Steuerelemente:
''---------------------------------------------------------------------
''Eine Listbox mit Namen LB1
''Ein Commandbutton mit Namen cmdSuche
''Eine Textbox mit Namen txtSuche
''---------------------------------------------------------------------
Option Explicit
Private Sub cmdSuche_Click()
Dim rngC As Range, strAddress As String, varSB As Variant, lngX As Long
Dim lngZ As Long
If txtSuche = "" Then Exit Sub
varSB = txtSuche
With [a1:e65536]
Set rngC = .Find(varSB, LookIn:=xlValues, Lookat:=xlPart)
If Not rngC Is Nothing Then
strAddress = rngC.Address
Do
On Error GoTo ENDE
lngX = lngX + 1
lngZ = rngC.Row
With LB1
.AddItem Cells(lngZ, 1)
.List(.ListCount - 1, 1) = Cells(lngZ, 2)
.List(.ListCount - 1, 2) = Cells(lngZ, 3)
.List(.ListCount - 1, 3) = Cells(lngZ, 4)
.List(.ListCount - 1, 4) = Cells(lngZ, 5)
End With
Set rngC = .FindNext(rngC)
Loop While Not rngC Is Nothing And rngC.Address <> strAddress
End If
End With
If lngX = 0 Then
ENDE:
MsgBox varSB & " wurde nicht gefunden! ", 64, "stelle fest..."
End If
txtSuche = ""
txtSuche.SetFocus
End Sub