Reputation: 2237
I wish to loop through values in a column. But the column is expanding and I don't want to change the range values every time I wish to add another entry to the column.
It is really frustrating that Google doesn't bother to add basic functionalities such as calling a row or a column!
Upvotes: 0
Views: 833
Reputation: 1280
To loop through every item in a column is actually very simple.
var column // int value of your column,
// assuming you know which column you want.
// (technically, your column number -1
var numRows = yourSheet.getLastRow();
for (var i; i < numRows; i++) {
cell = table.getCell(i, column);
// If you want to store all the cells text
list.push(cell.getText());
}
Easy as that. If you want every cell of the table, just loop j inside i, and getCell(i, j);
Upvotes: 1