以下代码在粗体线上给了我一个应用程序定义或对象定义的错误。我设定范围;但是,显然excel无法读取它。我不确定为什么会出现该错误。任何帮助深表感谢!谢谢。
Public Sub specialattention()
'Loop to check whether issue needs spcial attention
Dim n As Variant
Dim nend As Range
Dim nrng As Range
Dim nnow As Date
Dim ninterval As Integer
ninterval = Sheets("Ranges").Range("AB3").Value
nnow = Sheets("Issues Database").Range("N5").Value
Set nend = Sheets("Issues Database").Range("M1048576").End(xlUp)
Set nrng = Sheets("Issues Database").Range("M6", nend)
For Each n In nrng
If n.Value = "1" And nnow - n.Offset(0, 1).Value >= ninterval Then
n.Offset(0, 2).Value = "1"
Else
n.Offset(0, 2).Value = "0"
End If
'Color Cells that need special attention
If n.Offset(0, 2).Value = "1" Then
Dim xrng1 As Range
Dim xrng2 As Range
Set xrng1 = n.Offset(0, -11)
Set xrng2 = n.Offset(0, -1)
**Sheets("Issues Database").Range(xrng1, xrng2).Interior.ColorIndex = 19**
Else
Dim xrng3 As Range
Dim xrng4 As Range
Set xrng3 = n.Offset(0, -11)
Set xrng4 = n.Offset(0, -1)
**Sheets("Issues Database").Range(xrng2, xrng3).Interior.ColorIndex = 2**
End If
Next
End Sub