Skip to content

Instantly share code, notes, and snippets.

@stoneacheck
Created April 27, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stoneacheck/10abd1d9aa9a8b8e0432 to your computer and use it in GitHub Desktop.
Save stoneacheck/10abd1d9aa9a8b8e0432 to your computer and use it in GitHub Desktop.
function shortenUrl() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var longUrls = sheet.getRange("J3:J10").getValues();
var writeValues = []
for (var i =1 ; i <= numRows; i++) {
var row = []
var numRows = longUrls.getNumRows();
var numCols = longUrls.getNumColumns();
for (var j = 1; j <= numCols; j++) {
var url = UrlShortener.Url.insert({
longUrl: longUrls});
var shortUrl = url.id;
row.push(shortUrl)
}
writeValues.push(row)
}
sheet.getRange("M3:M10").setValues(writeValues)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment