# Sum the numbers Generated by Macro within macro.

#### 3PlankWalker

##### Board Regular
I have this Macro to print the numbers 1 to 10 in three rows As shown in the image below View image: Sum

Code:
``````Sub SumLoop()Dim a(1 To 3), Count, d, i As Integer
a(1) = 1
a(2) = 2
a(3) = 4

For i = 1 To UBound(a)
d = 0
Count = 0
Do While d < 10
Count = Count + 1
d = d + 1
Cells(Count, 1 + Count2).Value = d
Loop
Count2 = Count2 + 1
Next i
End Sub``````

How can i add the D1=A1+B1+C1, D2=A2+B2+C2 ...
within the macro

### Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

#### MickG

##### MrExcel MVP
Try this:-
Code:
``````Sub SumLoop()
Dim a(1 To 3), Count, d, i As Integer
Dim count2
a(1) = 1
a(2) = 2
a(3) = 4

For i = 1 To UBound(a)
d = 0
Count = 0
Do While d < 10
Count = Count + 1
d = d + 1
Cells(Count, 1 + count2).Value = d
[B]            Cells(Count, 4) = Application.Sum(Cells(Count, 1).Resize(, 3).Value)[/B]
Loop
count2 = count2 + 1
Next i
End Sub``````

Thanks It works.

You're welcome

Replies
3
Views
57
Replies
4
Views
70
Replies
2
Views
67
Replies
16
Views
199
Replies
9
Views
29