vba - Cumulative Sum in a column -
i trying write vba code run cumulative sum matrix of variable size output sheet further analysis. these cells need offset 1 row , 1 column new top row assigned "0" value. such shown below (done manual calc)
i struggling develop code have shown below.
'private sub lgmethod_click() 'declare variables dim integer dim j integer 'clear worksheet worksheets("lg").cells.clear 'loop count , and analyse = 1 worksheets("data").cells(rows.count, "a").end(xlup).row j = 1 worksheets("data").cells(1, columns.count).end(xltoleft).column worksheets("lg").cells(i + 1, j + 1) = application.worksheetfunction.sum(worksheets("data").range.cells(1, i)) next next end sub'
as see example, want shift down 1 row , calculate @ each cell cumulative sum on column.
dim integer, j integer, nrows integer, ncols integer worksheets("data") nrows = .cells(.rows.count, "a").end(xlup).row ncols = .cells(1, .columns.count).end(xltoleft).column worksheets("lg").cells.clear = 1 nrows j = 1 ncols worksheets("lg").cells(i + 1, j) = application.sum(.range(.cells(1, j), .cells(i, j))) next next j = 1 ncols + 2 worksheets("lg").cells(1, j) = 0 next end
Comments
Post a Comment