Я все еще начинающий пользователь VBA.Я не могу понять, почему этот фрагмент сценария не работает.Я получаю
'Subscript Out of Range' ошибку
во второй строке оператора If
ниже:
Sub ScreenUpdate()
Dim LastRow As Long, LastColumn As Long, i As Long, j As Long
Application.ScreenUpdating = False
LastRow = Range("C" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, 17).Value = Cells(i - 1, 17).Value Then
Cells(i, 1).NumberFormat = ";;;"
Cells(i, 2).NumberFormat = ";;;"
Cells(i, 15).NumberFormat = ";;;"
Cells(i, 16).NumberFormat = ";;;"
Else
Cells(i, 1).NumberFormat = "0"
Cells(i, 2).NumberFormat = "0"
Cells(i, 15).NumberFormat = "0"
Cells(i, 16).NumberFormat = "0"
End If
Next i
For j = 2 To LastRow
If Cells(j, 17).Value Mod 2 = 1 Then
Range(Cells(j, 1), Cells(j, 16)).Interior.ColorIndex = RGB(221, 235, 247)
Else
Range(Cells(j, 1), Cells(j, 16)).Interior.ColorIndex = RGB(255, 255, 255)
End If
Next j
Application.ScreenUpdating = True
End Sub
Большое спасибо за вашу помощь!