Option
Compare Text
Sub
Ersetze2()
Dim
iZelle
As
Long
, iSpalte
As
Long
, iCheck
As
Integer
Dim
sSuch1
As
String
, sSuch2
As
String
, sErsetz
As
String
sSuch1 =
"Apfel"
: sSuch2 =
"Birne"
: sErsetz =
"Apfelkuchen"
For
iZeile = 1
To
Cells(Rows.Count,
"A"
).
End
(xlUp).Row
iCheck = 0
For
iSpalte = 1
To
Columns.Count
If
Cells(iZeile, iSpalte).Value
Like
(
"*"
& sSuch1 &
"*"
)
Then
iCheck = (iCheck
Or
1)
If
Cells(iZeile, iSpalte).Value
Like
(
"*"
& sSuch2 &
"*"
)
Then
iCheck = (iCheck
Or
2)
Next
iSpalte
If
iCheck = 3
Then
For
iSpalte = 1
To
100
If
Cells(iZeile, iSpalte).Value
Like
"*Apfel*"
Then
Cells(iZeile, iSpalte).Value = Replace(Cells(iZeile, iSpalte).Value, sSuch1, sErsetz)
End
If
Next
iSpalte
End
If
Next
iZeile
End
Sub