Sub program() Const n = 30 Dim a(1 To 30) As Integer, i As Integer, Sum As Integer For i = 1 To n a(i) = Int(100 * Rnd) Sheets("Лист1").Cells(i, 1) = a(i) Next i Sum = 0 For i = 1 To n If a(i) < 80 And a(i) Mod 5 = 0 Then Sum = Sum + a(i) End If Next i For i = 1 To n If a(i) < 80 And a(i) Mod 5 = 0 Then Sheets("Лист1").Cells(i, 2) = Sum Else Sheets("Лист1").Cells(i, 2) = a(i) End If Next iEnd Sub