writing macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've a 1000 number entries (i.e n = 1000). I want to sum then in tens, that
is, 1-10, 2-11, 3-12,...990-1000). I want to do this using excel macro.
Please will somebody write the code for me?
 
In you first output cell enter

=SUMPRODUCT(--(ROW($A$1:$A$1000)>(ROW(A1)-1)*10),--(ROW($A$1:$A$1000)<=ROW(A
1)*10),$A$1:$A$1000)

and copy down until you run out

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Assume you values are in A1:A1000 then

Sub SumByTen()
Dim i As Long, j As Long
j = 10
For i = 1 To 991
Cells(j, 2).Value = Application.Sum(Cells(i, 1).Resize(10))
Cells(j, 3).Value = "'" & i & " - " & i + 9
j = j + 1
Next
End Sub


The last sum would be 991 to 1000, not 990 to 1000
 
that
That does
1 - 10
11 - 20

not
1 - 10
2 - 11
3 - 12



=sum(A1:A10)

and copy down.
would be the formula solution, although the OP asked for a macro.
 
Back
Top