Thread
:
Sum macro for a variable "i" in a loop
View Single Post
#
3
Posted to microsoft.public.excel.programming
JE McGimpsey
external usenet poster
Posts: 4,624
Sum macro for a variable "i" in a loop
One way:
Public Sub test()
Dim i As Integer
For i = 1 To 100
Range("A1").Value = _
Application.WorksheetFunction.Sum("B2:B" & i)
Next i
End Sub
In article .com,
wrote:
I am trying to do the following sum macro but I get an error for the
sum fomula. I want to sum the values from range B2 to B&i, the
corresponding value of "i".. Please let me know how do I do this.
Thanks
Sub test()
Dim i As Integer
For i = 1 To 100
Range("A1").Value = Sum(Range(B2, B&i))
Next i
End Sub
Reply With Quote
JE McGimpsey
View Public Profile
Find all posts by JE McGimpsey