ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with updating formulas (https://www.excelbanter.com/excel-programming/323475-help-updating-formulas.html)

Jason[_35_]

Help with updating formulas
 
I'm looking for a way to code using VBA a cell's formula to sum every
50th cell (in the same column) to the point it finds a cell with a null
value.

Any simple way of doing this?

Thanks for any assistance!
Jason


Chip[_3_]

Help with updating formulas
 
So you want to be able to put in a function so that it will go every 50
cells (from the first cell in that column? or 50 rows down from where
the cell that you are putting the formula is located?) and sum it up
until it reaches an empty cell.

So they would put in a cell:
=sum50()

And it will return a number.

824
???


Jason[_35_]

Help with updating formulas
 
If I have a formula in Cell A1 it would sum the cells A51, A101, A151
and so on until it reachs an empty cell.


Chip[_3_]

Help with updating formulas
 
Yea but what if the formula is in Cell A2? Is it still A51+A101, or is
it A52+A102?


Chip[_3_]

Help with updating formulas
 
If it is always from 50 cells down from where the formula is put in,
then this should work:

Function sum50()

currentrow = ActiveCell.Row
currentcolumn = ActiveCell.Column
sumtotal = 0
Do Until IsEmpty(Cells(currentrow + 50, currentcolumn))
sumtotal = Cells(currentrow + 50, currentcolumn).Value + sumtotal
currentrow = currentrow + 50
Loop
sum50 = sumtotal
End Function


Jason[_35_]

Help with updating formulas
 
It's dependant on the cell the formula is in...therefore if in Cell A2
it would be A52+A102 and so on.
In the spreadsheet I'm using a summary table at the top of the
spreadsheet has a running total of other tables inserted below it (same
template used for all).


Jason[_35_]

Help with updating formulas
 
Thanks Chip! I think this function will work well for me.
Jason.



All times are GMT +1. The time now is 11:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com