I am running the following code which looks at two different cell values to determine if a date/time should be inserted into a third cell. I am receiving a Run-Time91 error and it is highlighting the "If On5.Value" line. This procedure is called inside another procedure which causes a change to the cells values. Any ideas on why I'm getting the error?
Code
Dim wksht1 As Worksheet
Dim On5 As Range, On6 As Range, On7 As Range
Dim rng5 As Range, rng6 As Range, rng7 As Range
Dim stp5 As Range, stp6 As Range, stp7 As Range
Set wksht1 = Sheets("Nucomat_Dashboard")
Set On5 = Range("N13").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole)
Set On6 = Range("N14").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole)
Set On7 = Range("N15").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole)
Set rng5 = wksht1.Range("AA2:AA9").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlUp)
Set rng6 = wksht1.Range("AA11:AA16").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlUp)
Set rng7 = wksht1.Range("AA19:AA24").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlUp)
Set stp5 = wksht1.Range("AB2:AB9").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlUp)
Set stp6 = wksht1.Range("AB11:AB16").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlUp)
Set stp7 = wksht1.Range("AB19:AB24").Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole, SearchDirection:=xlUp)
With Sheets("Nucomat_Dashboard")
If On5.Value = 0 And rng5.End(xlUp).Value = "*" Then
stp5.End(xlUp).Offset(1, 0).Value = Now()
Else
End If
If On6.Value = 0 And rng6.End(xlUp).Value = "*" Then
stp6.End(xlUp).Offset(1, 0).Value = Now()
Else
End If
If On7.Value = 0 And rng7.End(xlUp).Value = "*" Then
stp7.End(xlUp).Offset(1, 0).Value = Now()
Else
End If
End With
End Sub
Display More