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.

enter image description here

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

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -