ich habe das Problem, dass ich einen variablen Bereich in Spalte B habe. Wenn wie hier ein fester Bereich definiert ist und alle Zellen in diesem Bereich gefüllt sind, funktioniert der Code. Wenn nicht alle Zellen gefüllt sind habe ich ein Problem ab dem leeren Bereich.
Dim FindWert As Range, werte As Range
Dim SP As Variant, suche As Variant
Sheets("TRAIN_KOMALOG").Select
<b>For Each werte In Range("B2:B10") 'Bsp. diese werte suche B2 bis B10</b><i></i>
Sheets("Aufträge").Select
Set FindWert = Columns("B:B").Find(What:=werte, After:=Range("B1"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If FindWert Is Nothing Then GoTo nächste:
SP = FindWert.Address
FindWert.Offset(0, 4) = "e"
For suche = 1 To Application.WorksheetFunction.CountA(Columns("B:B"))
Set FindWert = Columns("B:B").FindNext(After:=FindWert)
If FindWert Is Nothing Then GoTo nächste:
If SP = FindWert.Address Then GoTo nächste:
FindWert.Offset(0, 4) = "e"
Next suche:
nächste:
Next werte
Gruß Ralf