Thursday, July 28, 2011

Google Apps Script Tip #1: Finding the last row


I've been building some custom reports for Portent in Google Spreadsheets. They do fun stuff like grab Google Analytics data, insert data from other APIs and such.

One thing that nearly drove me batty, though, was figuring out how to automatically add a new row below the last row with data.

Turns out, Google App Script has it's own nifty command, called getLastRow. Here's how you do it:

function FindRows() {
range = SpreadsheetApp.getActiveSheet().getLastRow();
return range;
}

That's it. It'll return the value range. That value is the number of the last row on the sheet that has data. You can then pass that back to other functions to start adding new rows in the right place, delete rows, etc..

If this is all gibberish, fear not. Marketing Ian will be back Monday. Today is Nerd Ian.

Source: http://feedproxy.google.com/~r/conversationmarketing/MRJI/~3/eKiT5t8Ef3o/google-app-script-1.htm

sports illustrated swimsuit 2011 bonnaroo 2011 lineup rumors medal of freedom sing it for the boys sing it for the girls bonaroo 2011

No comments:

Post a Comment