sum data in a range?

P

pemt

hi,

i need to sum data from every 100 rows from top to bottom of total 50,000
rows. how to do it?
my data have two columns:
id score
1 45
2 60
3 85
.. .
.. .
.. .
100 96
.. .

so, the sum of 1st 100 rows =45+60+85+...+96
then next 100 rows, ... until to 50,000 rows.

thanks for your help.

pemt
 
D

Don Guillett

Use this to test and then change to step 10, resize 9

Sub sumeverfewrows()
For i = 1 To Cells(Rows.Count, "a").End(xlUp).Row Step 4
MsgBox Application.Sum(Cells(i, "b"), Cells(i, "b").Resize(3))
Next i
End Sub
 
D

Don Guillett

Use this to test and then change to step 10, resize 9

Sub sumeverfewrows()
For i = 1 To Cells(Rows.Count, "a").End(xlUp).Row Step 4
MsgBox Application.Sum(Cells(i, "b"), Cells(i, "b").Resize(3))
Next i
End Sub
 
R

Ragdyer

Say values in Column B, starting in B1 down:

Enter this formula *anywhere* (except Column B), and copy down as needed:
=SUM(INDEX(B:B,100*ROWS($1:1)-99):INDEX(B:B,ROWS($1:1)*100))
 
R

Ragdyer

Say values in Column B, starting in B1 down:

Enter this formula *anywhere* (except Column B), and copy down as needed:
=SUM(INDEX(B:B,100*ROWS($1:1)-99):INDEX(B:B,ROWS($1:1)*100))
 
P

pemt

thanks a lot!

Don Guillett said:
Use this to test and then change to step 10, resize 9

Sub sumeverfewrows()
For i = 1 To Cells(Rows.Count, "a").End(xlUp).Row Step 4
MsgBox Application.Sum(Cells(i, "b"), Cells(i, "b").Resize(3))
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
 
P

pemt

thanks a lot!

Don Guillett said:
Use this to test and then change to step 10, resize 9

Sub sumeverfewrows()
For i = 1 To Cells(Rows.Count, "a").End(xlUp).Row Step 4
MsgBox Application.Sum(Cells(i, "b"), Cells(i, "b").Resize(3))
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
 
P

pemt

thanks a lot!

Ragdyer said:
Say values in Column B, starting in B1 down:

Enter this formula *anywhere* (except Column B), and copy down as needed:
=SUM(INDEX(B:B,100*ROWS($1:1)-99):INDEX(B:B,ROWS($1:1)*100))
 
P

pemt

thanks a lot!

Ragdyer said:
Say values in Column B, starting in B1 down:

Enter this formula *anywhere* (except Column B), and copy down as needed:
=SUM(INDEX(B:B,100*ROWS($1:1)-99):INDEX(B:B,ROWS($1:1)*100))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top