Hi,
Solution can be based on:
1. iterating through selected cells
2. detecting row's break
3. place current sum to a cell next to the last of row in the selection
I.e. like this:
var mT = app.selection[0].cells.everyItem().getElements(), currSum, sumCell, len = mT.length, currCell, prevCell; while (len-->0) { currCell = mT[len]; prevCell = mT[len-1]; currSum = Number(currCell.contents); sumCell = currCell.parentRow.cells.nextItem(currCell); while (prevCell && currCell.parentRow == prevCell.parentRow && len-->0) { currSum += Number(prevCell.contents); currCell = mT[len]; prevCell = mT[len-1]; } sumCell.contents = currSum.toString(); }
Jarek