excel vba - Adding sum formula between every space ranges by vba -
i trying automation , stuck here, need add sum formula dynamically in between space ranges. i'm lost here adding formula using vba can me out.
thank in advance :)
i'm assuming want if there blank in cell, want of other elements summed , result placed in blank. there number of ways code this, here attempt
sub formulatesubtotals() finalrow = cells(worksheets("sheet1").rows.count, 1).end(xlup).row finalcol = cells(1, worksheets("sheet1").columns.count).end(xltoleft).column j = 1 finalcol = finalrow + 1 1 step -1 if isempty(cells(i, j)) if isempty(cells(i - 2, j)) firstrow = - 1 lastrow = firstrow else lastrow = - 1 firstrow = cells(i - 1, j).end(xlup).row end if cells(i, j) = application.worksheetfunction.sum(range(cells(firstrow, j), cells(lastrow, j))) end if next next j end sub
this assumes sheet in question entitled "sheet1".
Comments
Post a Comment