I made a VB makro in Excel to execute something if the cell is in a given range but when I execute it it gives me an error and I don't see why.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Boolean
isect = Application.Intersect(Selection, Range("D11:D35"))
If isect Then
If ActiveCell.Offset(-1, 0) - ActiveCell.Offset(-1, 1) > 2.5 Then
Range("A1:A1").Value = "ok"
End If
End If
End Sub
The error is:
Object variable or With block variable not set.