Makro Fehlerhaft
16.08.2022 19:13:35
Basti
folgendes Makro zeigt an der gekennzeichneten Stelle einen Fehler an:
Fehlermeldung = "Objektvariable oder With-Blockvariable nicht festgelegt"
Weißt Du wo der Fehler liegen könnte?
----
Sub Test_1()
Application.Calculation = xlManual
Application.ScreenUpdating = False
Application.EnableEvents = False
Dim C As Range, rngCopy As Range
Dim OEA As Range, rng2Copy As Range
With ThisWorkbook.Worksheets("TESTsheet1")
For Each C In .Range("C2:C" & .Cells(Rows.Count, "B").End(xlUp).row)
If Left(C, 1) = "8" Then
Set rngCopy = .Range("B" & C.row & ":D" & C.row)
With ThisWorkbook.Worksheets("TESTsheet2")
rngCopy.Copy Destination:=.Cells(.Rows.Count, 2).End(xlUp).Offset(1, 0)
End With
Else
With ThisWorkbook.Worksheets("TESTsheet2")
Set OEA = .Range("F2:AE2").Find(C, LookIn:=xlValues)
Set rng2Copy = .Range(.Cells(4, OEA.Column), .Cells(.Cells(.Rows.Count, OEA.Column).End(xlUp), OEA.Column))
rngCopy.Copy Destination:=.Cells(.Rows.Count, 3).End(xlUp).Offset(1, 0)
Set .Range("B" & C.row & ":B" & C.row + rng2Copy.Count) = ThisWorkbook.Worksheets("TESTsheet1").Range("B" & C.row).Value
End With
End If
Next
End With
----
Danke für Deine Rückmeldung im Voraus
Viele Grüße
Basti