Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save irvinebroque/a6ef4625ec6a7fba5428 to your computer and use it in GitHub Desktop.
Save irvinebroque/a6ef4625ec6a7fba5428 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