I have a wokrbook with muliple sheets.
On my second sheet I have a little macro which works pretty good, but if want to run it, while i'm on a other sheet, excel vba shows me a bug and its not working.
This is my code:
Dim myDate As Variant, rng As Range
Dim lastRow As Integer, penultimateRow As Integer
Set rng = Range("A1:A207")
Set myDate = rng.Find(What:=Int(Date), LookIn:=xlFormulas)
Worksheets("Lernzeit-Tracking").Cells(myDate.Row, myDate.Column + 1).Value = _
Worksheets("Übersicht").Range("L20").Value
With Worksheets("Lernzeit-Tracking")
penultimateRow = .Cells(.Cells(Rows.Count, 2).End(xlUp).Row, 2).End(xlUp).Row
lastRow = .Cells(Rows.Count, 2).End(xlUp).Row
End With
If IsEmpty(Sheets("Lernzeit-Tracking").Cells(lastRow - 1, 2)) = True Then
Sheets("Lernzeit-Tracking").Range(Cells(penultimateRow + 1, 2), Cells(lastRow - 1, 2)).Value = 0
End If
The Error message says:
"Object variable not set"
and the line
Worksheets("Lernzeit-Tracking").Cells(myDate.Row, myDate.Column + 1).Value == Worksheets("Übersicht").Range("L20").Value
is marked
How can i run my macro while wokring on a other sheet?