Доброго дня! Помогите пожалуйста, не могу сообразить, как сделать. Необходимо распределить суммы годового КАСКО и ОСАГО, на последующие месяцы. Например, купив ОСАГО условно на 12000 рублей в ноябре 2017 года, мы должны разложить эту сумму на ноябрь17-октябрь18 по одной тысячи рублей в месяц. Прикладываю файл для примера.
Sub iRazlozhit()
Dim i As Long
Dim iLastRow As Long
Dim iLastCol As Integer
Dim j As Integer
iLastRow = Cells(Rows.Count, 1).End(xlUp).Row
iLastCol = Cells(2, Columns.Count).End(xlToLeft).Column
Range(Cells(12, 2), Cells(iLastRow, iLastCol)).ClearContents
iLastRow = Range("A3").End(xlDown).Row
For i = 3 To iLastRow
For j = 2 To iLastCol
If Cells(i, j) <> "" Then
Cells(i + 9, j).Resize(, 12) = Cells(i, j) / 12
End If
Next
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
If Target.Column = 1 Or Target.Row = 1 Then Exit Sub
If Target.Value = "" Or Target.Value = 0 Then Exit Sub
aaa = Target.Value
Application.EnableEvents = False
For i = 1 To 12
Cells(Target.Row, Target.Column - 1 + i).Value = aaa / 12
Next i
Application.EnableEvents = True
End Sub