Option
Explicit
Sub
PerPedes()
Const
SuchWort
As
String
=
"abgerechnet"
Const
SuchSpalte
As
Long
= 3
Const
Wert
As
Integer
= 3
Dim
c
As
Range
Dim
la
As
Long
, lr
As
Long
Dim
x
As
Long
Set
c = Selection
la = c.Row
lr = Cells.Find(
"*"
, [a1], , , xlByRows, xlPrevious).Row
Rem Von der aktiven Zelle aus - suche in Spalte C nach erstem Wort
"abgerechnet"
For
x = la
To
lr
If
Cells(x, SuchSpalte).Value = SuchWort
Then
Set
c = Cells(x, SuchSpalte - 1)
If
c.Value =
""
Then
c.Value = Wert
Else
MsgBox (
"Bereits vorhanden!"
)
End
If
Exit
Sub
End
If
Next
x
Rem nach unten nicht gefunden
Rem dann eben nach gewünschter Methode die Schleife über
Rem for x = la-1 to 1 step -1
Rem oder
Rem for x = 1 to la -1
End
Sub