Two Plus Two Newer Archives  

Go Back   Two Plus Two Newer Archives > Internet Gambling > Software
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-09-2006, 11:48 AM
Nottom Nottom is offline
Senior Member
 
Join Date: Feb 2003
Location: Carpal \\\'Tunnel 4 Life
Posts: 9,412
Default Excel question

OK I have a long list of data points and would like to find the sum of each group of 100.

i.e. I want the sum of the 1st 100, 2nd 100, 3rd 100, etc

Obviously for a long list 20K+, I don't want to have to type "=SUM(A1:A100)", "=SUM(A101:A200), etc"

How can I do this easily?
Reply With Quote
  #2  
Old 04-09-2006, 12:43 PM
TheIrishThug TheIrishThug is offline
Senior Member
 
Join Date: Jan 2005
Location: Belligerent and numerous
Posts: 1,819
Default Re: Excel question

Open excel
Tools>Marco>Visual Basic Editor
On the left there should be a menu that is titled VBAProject. Right click in there and select Insert>Module
In the window that appears paste the following. You can adjust the variables as necesary. Then Run>Run Sub/UserForm

<font class="small">Code:</font><hr /><pre> Sub WriteFormulas()
Dim RowStart As Integer
Dim ColumnForSum As String
Dim Grouping As Integer
Dim RowsToSum As Integer
Dim FormulaColumn As String
Dim FormulaFirstRow As Integer
Dim SumRowNumber As Integer
Dim FormulaRowNumber As Integer
'---------------------------------
' Set Variables
'---------------------------------
RowStart = 1
ColumnForSum = "A"
Grouping = 100
RowsToSum = 500
FormulaColumn = "B"
FormulaFirstRow = 1
'---------------------------------
SumRowNumber = RowStart
FormulaRowNumber = FormulaFirstRow
While (SumRowNumber &lt;= RowStart + RowsToSum)
Range(FormulaColumn &amp; FormulaRowNumber).Formula = "=sum(" &amp; ColumnForSum &amp; SumRowNumber &amp; ":" &amp; ColumnForSum &amp; (SumRowNumber + Grouping - 1) &amp; ")"
SumRowNumber = SumRowNumber + Grouping
FormulaRowNumber = FormulaRowNumber + 1
Wend
End Sub
</pre><hr />
Reply With Quote
  #3  
Old 04-09-2006, 01:04 PM
Nottom Nottom is offline
Senior Member
 
Join Date: Feb 2003
Location: Carpal \\\'Tunnel 4 Life
Posts: 9,412
Default Re: Excel question

Thanks.

I get an overflow error if I try to do it with more than 30K rows or so however, guess I'm just trying to push poor excel too hard [img]/images/graemlins/frown.gif[/img]
Reply With Quote
  #4  
Old 04-09-2006, 01:23 PM
TheIrishThug TheIrishThug is offline
Senior Member
 
Join Date: Jan 2005
Location: Belligerent and numerous
Posts: 1,819
Default Re: Excel question

Change the "As Integer" to "As Long"
that'll let u do 2,147,486,647 rows
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.