I want to distribute value of a cell into different cells.
e.g. For 200 I want it to be distributed into 4 cells of 50 each and for 120 it should have 2 cells of 50 and one cell of 20
My data is attached.
When I created a macro the value in the last cell also comes as 50 whereas it should have only the remaining value
Sub macro2()
Dim z
Do While ActiveCell.Value < 2000
z = ActiveCell.Value / 50
Dim result As Integer
result = Round(z, o)
If result < z Then
result = result + 1
End If
ActiveCell.Offset(0, 2).Value = result
If z = 1 Then GoTo jump
If z >= 2 Then
z = z - 1
End If
If ActiveCell.Value < 50 Then GoTo last
For i = 1 To result - 1
Rows(ActiveCell.Row + i).Insert
ActiveCell.Offset(i - 1, 1).Value = 50
Next i
jump:
ActiveCell.Offset(i - 1, 1).Value = 50
last:
ActiveCell.Offset(1, 0).Select
Loop
End Sub
Thanks in advance for the help