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)

manual analysis

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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -