Option
Explicit
Public
Sub
test()
Dim
objCell
As
Range, objRange
As
Range, objUnion
As
Range
Dim
lngIndex
As
Long
Dim
strText
As
String
Set
objRange = Range(
"A1:A20"
)
For
lngIndex = 1
To
3
Set
objCell = objRange.Find(What:=WorksheetFunction.Small(objRange, lngIndex), LookIn:=xlValues, LookAt:=xlWhole)
If
Not
objCell
Is
Nothing
Then
With
objCell
If
objUnion
Is
Nothing
Then
strText =
"gefundene Werte:"
& vbCr & vbCr & .Value &
" in Zeile: "
& .Row
Set
objUnion = objCell
Else
strText = strText & vbCr & .Value &
" in Zeile: "
& .Row
Set
objUnion = Union(objUnion, objCell)
End
If
End
With
End
If
Next
If
objUnion
Is
Nothing
Then
Call
MsgBox(
"Werte konnte nicht gefunden werden..."
, vbExclamation)
Else
If
MsgBox(strText & vbCr & vbCr &
"Möchten sie die Zeilen löschen?"
, _
vbYesNo + vbQuestion,
"Löschabfrage"
) = vbYes
Then
_
Call
objUnion.EntireRow.Delete
End
If
Set
objCell =
Nothing
Set
objRange =
Nothing
Set
objUnion =
Nothing
End
Sub