AW: Suche Text in Spalte und prüfe Zeile
20.03.2021 14:57:17
Nepumuk
Hallo Mani,
teste mal:
Option Explicit
Public Sub Suchen()
Dim objCell1 As Range, objCell2 As Range
Dim strFirstAddress1 As String, strFirstAddress2 As String
Dim lngRow As Long
Set objCell1 = Columns(1).Find(What:="Hallo", LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=True)
If Not objCell1 Is Nothing Then
strFirstAddress1 = objCell1.Address
Do
lngRow = objCell1.Row
Set objCell2 = Rows(lngRow).Find(What:=1, _
LookIn:=xlValues, LookAt:=xlWhole)
If Not objCell2 Is Nothing Then
strFirstAddress2 = objCell2.Address
Do
objCell2.Offset(1, 0).Interior.Color = vbRed
Set objCell2 = Rows(lngRow).FindNext(after:=objCell2)
Loop Until objCell2.Address = strFirstAddress2
Set objCell2 = Nothing
End If
Set objCell1 = Columns(1).Find(What:="Hallo", after:=objCell1, _
LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
Loop Until objCell1.Address = strFirstAddress1
Set objCell1 = Nothing
Else
Call MsgBox("Suchbegriff nicht gefunden.", vbExclamation, "Hinweis")
End If
End Sub
Gruß
Nepumuk