Sternchen als Suchersatz
28.11.2006 09:05:44
otto
ich lasse mir in einer Listbox alle Einträge die mit Suchkriterium in einer Textbox übereinstimmen auflisten. gebe ich z.B. "bf" ein erscheinen alle Einträge die mit "BF" beginnen, usw.
Wie kann ich folgenden Code ändern, dass ich z.B. die Zeichenfolge "BF2010" auch finde wenn ich "*f2010" eingebe, weil es mir auch "WF2010" mit anzeigen soll?
Dim arr() As Variant, Tmp As Variant, wks As Worksheet, zelle
Dim index As Integer
Dim x, iCount
zelle = Cells(12, 4)
Set wks = Sheets("Stamm")
x = wks.Range("V65536").End(xlUp).Row
Tmp = wks.Range("V9:CH" & 9 + x) ', Cells(x, 86))
x = x - 9
If TextBox1 = "" Then
On Error GoTo weiter
ReDim arr(0 To 2, 0 To x - 1)
For index = 1 To UBound(Tmp, 1)
arr(0, iCount) = Tmp(index, 4)
arr(1, iCount) = Tmp(index, 65)
arr(2, iCount) = Tmp(index, 1)
Next
weiter:
arr = WorksheetFunction.Transpose(arr)
ListBox1.List = arr
Else
For index = 1 To UBound(Tmp, 1)
If LCase(Left(Tmp(index, 4), Len(TextBox1))) = LCase(TextBox1) Then
ReDim Preserve arr(0 To 2, 0 To iCount)
arr(0, iCount) = Tmp(index, 4)
arr(1, iCount) = Tmp(index, 65)
arr(2, iCount) = Tmp(index, 1)
iCount = iCount + 1
End If
Next
End If
If iCount > 0 Then
arr = WorksheetFunction.Transpose(arr)
ListBox1.List = arr
End If
Danke im Voraus
otto