Dim
xSuche
As
String
, xAdresse
As
String
, xErste
As
String
Dim
y
As
Boolean
Dim
arr()
As
Variant
Dim
rng
As
Range
Dim
iRowU
As
Integer
ListBox_Ergebnisse.Clear
ListBox_Ergebnisse.ColumnCount = 2
xSuche = TextBox_Suchbegriff.Value
If
xSuche =
""
Then
MsgBox
"Bitte geben Sie einen Suchbegriff ein!"
, vbExclamation,
"Achtung!"
Exit
Sub
End
If
Set
rng = Worksheets(
"Adressen"
).Range(
"A:E"
).Find _
(xSuche, lookat:=xlWhole, LookIn:=xlValues)
If
Not
rng
Is
Nothing
Then
With
Worksheets(
"Adressen"
)
xErste = rng.Address(
False
,
False
)
y =
True
Do
Until
xAdresse = xErste
ReDim
Preserve
arr(0
To
1, 0
To
iRowU)
arr(0, iRowU) = .Cells(rng.Row, 1) &
" - "
& .Cells(rng.Row, 4) &
", "
& .Cells(rng.Row, 5)
arr(1, iRowU) = .Cells(rng.Row, 3)
iRowU = iRowU + 1
Set
rng = .Cells.FindNext(after:=rng)
xAdresse = rng.Address(
False
,
False
)
Loop
xAdresse =
""
xErste =
""
End
With
End
If
If
y =
False
Then
MsgBox
"Der Suchbegriff wurde nicht gefunden!"
Else
ListBox_Ergebnisse.Column = arr
End
If