Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 110690

Re: Summing cells in a row

$
0
0

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


Viewing all articles
Browse latest Browse all 110690

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>