Sub Çàïîëíèòü()
Dim Str1 As String, TimeService As Date, event_type_id As Integer, y As Integer
i = 1
serviceid = 1
While ActiveSheet.Cells(i + 1, 1).Value
i = i + 1
Str1 = "=E" + Str(i + 2) + "-" + "E" + Str(i)
serviceid = ActiveSheet.Cells(i, 7)
event_type_id = ActiveSheet.Cells(i, 2).Value
If event_type_id = 6 Then
If ActiveSheet.Cells(i + 1, 2).Value = 28 Then
ActiveSheet.Cells(i, serviceid).Formula = Replace(Str1, " ", "")
' TimeService = TimeService + ActiveSheet.Cells(i, 9)
y = y + 1
End If
If ActiveSheet.Cells(i + 3, 2).Value = 28 Then
ActiveSheet.Cells(i, serviceid).Formula = Replace(Str1, " ", "")
' TimeService = TimeService + ActiveSheet.Cells(i, 9)
y = y + 1
End If
End If
ActiveSheet.Cells(i + 1, 9).Value = i
Wend
Str1 = "=ÑÐÇÍÀ×(I2:I" + Str(i + 1) + ")"
ActiveSheet.Cells(i + 2, 10).FormulaLocal = Replace(Str1, " ", "")
End Sub