Я получаю ошибку времени выполнения 1004, определенную приложением или ошибкой, определенной объектом, которая обновила приведенную ниже функцию, добавив код «доступа».Я не могу найти, где моя проблема.У кого-нибудь есть вход?Я стар, мне нужно ввести больше деталей, но я не уверен, что мне следует написать, так что вот какой-то наполнитель?
Dim Access As Worksheet
Dim report As Worksheet
Dim complete As Worksheet
Sub finalOverlay()
Application.ScreenUpdating = False
Set Access = ActiveWorkbook.Worksheets("Access")
Set report = ActiveWorkbook.Worksheets("Report")
Set complete = ActiveWorkbook.Worksheets("Implementation Complete")
Dim i As Long
For x = 2 To Access.UsedRange.Rows.Count
For i = 2 To report.UsedRange.Rows.Count
getRemainingControls (i)
' update completed list if no more actions outstanding
If report.Cells(i, 17) = 0 Then
t = setComplete(report.Cells(i, 1), i)
End If
S = getComplete(report.Cells(i, 1), i)
' Add BAU Ageing
report.Cells(i, 22) = BAUAgeing(i)
' Disposition Date past
If report.Cells(i, 34) <> "" Then
If CDate(report.Cells(i, 34)) < Date Then
report.Cells(i, 34).Interior.ColorIndex = 3
End If
End If
' Proposed Status for too long
If report.Cells(i, 4) = "Proposed" Then
report.Cells(i, 18) = CInt(Date - CDate(report.Cells(i, 38)))
If report.Cells(i, 18) > 30 Then
report.Cells(i, 18).Interior.ColorIndex = 3
End If
End If
Next i
Next x
For n = 2 To report.UsedRange.Rows.Count
If report.Cells(n, 19) <> " " And _
report.Cells(n, 19) > 305 And _
report.Cells(n, 23) = "Yes" And _
report.Cells(n, 3) <> "LOW" And _
report.Cells(n, 39) <> "NO" Then
report.Cells(n, 19).Interior.ColorIndex = 45
End If
If report.Cells(n, 19) <> " " And _
report.Cells(n, 19) > 60 And _
report.Cells(n, 24) <> "Complete" And _
report.Cells(n, 24) <> "" And _
report.Cells(n, 23) = "Yes" And _
report.Cells(n, 3) <> "LOW" And _
report.Cells(n, 39) <> "NO" Then
report.Cells(n, 19).Interior.ColorIndex = 3
End If
If report.Cells(n, 20) > 305 And _
report.Cells(n, 20) < 364 And _
report.Cells(n, 29) = "Complete" And _
report.Cells(n, 23) = "Yes" And _
report.Cells(n, 3) <> "LOW" And _
report.Cells(n, 39) <> "NO" Then
report.Cells(n, 20).Interior.ColorIndex = 45
End If
If report.Cells(n, 20) > 60 And _
report.Cells(n, 29) <> "Complete" And _
report.Cells(n, 23) = "Yes" And _
report.Cells(n, 3) <> "LOW" And _
report.Cells(n, 39) <> "NO" Then
report.Cells(n, 20).Interior.ColorIndex = 3
End If
Next n
Application.ScreenUpdating = True
End Sub
Function BAUAgeing(i As Long)
If report.Cells(i, 17) > 0 And _
report.Cells(i, 6) <> "" And _
report.Cells(i, 23) = "No" Then
BAUAgeing = Date - CDate(report.Cells(i, 6))
Else
End If
If report.Cells(i, 4) = "Newly Disclosed" And Access.Cells(x, 35) = "" Then
BAUAgeing = Date - CDate(report.Cells(i, 38))
Else
BAUAgeing = Date - CDate(Mid(Access.Cells(x, 35), 16, 10))
End If
If report.Cells(i, 4) = "Proposed" And Access.Cells(x, 35) = "" Then
BAUAgeing = Date - CDate(report.Cells(i, 38))
Else
BAUAgeing = Date - CDate(Mid(Access.Cells(x, 35), 16, 10))
End If
End Function