Hi guys.
Starting with Cell B4, every 20 cells downwards I have a number.
I would like a code which will give me a total of all of these numbers.
So B4, B24, B44, B64....and so on.
Any ideas?
Last edited by twofootgiant; 07-04-2011 at 09:32 AM.
hi, twofootgiant, I hope I understood your question right
Hi watersev
Thanks for your resposne but I dont hink you understood correctly.
I have a sheet with lots of data. every 20 rows in column B there is a number. I need to find the total sum of those numbers.
So..the cells i need to add up are B4, B24, B44, B64...and so on....
The result will go into cell A1 of sheet2
please check attachment, run code "test", result in in E3
PS. In order to understand you correct it's good to have a file sample ...
Hi watersev, thanks for the reply.
How would I modify this so that it would add up the totals on one hidden sheet and place the total value on another hidden sheet?
please check attachment, run code "test" and make Sheet1 and Sheet2 visible to check result.
The code sums values on hidden sheet("Sheet1") and places result in hidden sheet("Sheet2"). There are two visible sheets showing layout of hidden sheets.
This formula should do that.
=SUMPRODUCT(--(MOD(ROW(B4:B400), 20)=4),B4:B400)
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
Hi watersev,
I am trying to modify the code to get the totals of multiple columns. But the totals do not add u correctly.
What am I doing wrong?
Private Sub CommandButton8_Click() Dim i As Long, temp As Double, myrange As Range 'info1 With Sheets("Master"): Set myrange = .Range(.[b3], .Cells(Rows.Count, "b").End(xlUp)) For i = 2 To myrange.Cells.Count Step 20: temp = temp + myrange(i): Next Sheets("Stats").[b7] = temp: End With: 'info2 With Sheets("Master"): Set myrange = .Range(.[c3], .Cells(Rows.Count, "c").End(xlUp)) For i = 2 To myrange.Cells.Count Step 20: temp = temp + myrange(i): Next Sheets("Stats").[c7] = temp: End With: 'info3 With Sheets("Master"): Set myrange = .Range(.[d3], .Cells(Rows.Count, "d").End(xlUp)) For i = 2 To myrange.Cells.Count Step 20: temp = temp + myrange(i): Next Sheets("Stats").[d7] = temp: End With: 'info4 With Sheets("Master"): Set myrange = .Range(.[e3], .Cells(Rows.Count, "e").End(xlUp)) For i = 2 To myrange.Cells.Count Step 20: temp = temp + myrange(i): Next Sheets("Stats").[e7] = temp: End With: 'info5 With Sheets("Master"): Set myrange = .Range(.[f3], .Cells(Rows.Count, "f").End(xlUp)) For i = 2 To myrange.Cells.Count Step 20: temp = temp + myrange(i): Next Sheets("Stats").[f7] = temp: End With: 'info6 With Sheets("Master"): Set myrange = .Range(.[g3], .Cells(Rows.Count, "g").End(xlUp)) For i = 2 To myrange.Cells.Count Step 20: temp = temp + myrange(i): Next Sheets("Stats").[g7] = temp: End With: Unload Me Sheets("Stats").Visible = True Sheets("Stats").Select End Sub
please check attachment example, run code "test".
Would not it be easier to post your workbook sample?
Hi watersev,
please find attached an example of what I am trying to do. this should show how the results should look after the code has been run.
Thanks
dont worry guys, worked it out myself![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks