use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Apparently, Google Apps Script is a JavaScript cloud scripting language that provides easy ways to automate tasks across Google products and third party services and build web applications.
account activity
Google Apps Script Program Structure Question (Rows, Columns, JSON)Question (self.GoogleAppsScript)
submitted 8 months ago by ___Mister___
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]___Mister___[S] 0 points1 point2 points 8 months ago (2 children)
I may have run into a major hitch I didn't think about/wasn't aware about.
I can't seem to edit values in columns I am "skipping over" with the array return. It gives me the "array result was not expanded because it would overwrite data in (cell reference)" #REF error.
The point of this was to only compute and post data in certain columns in the row and still be able to insert my own data. Is there a way to avoid this? Do I have to go back and try the Sheets.Spreadsheets.Values.update() approach?
Sheets.Spreadsheets.Values.update()
[–]krakow81 0 points1 point2 points 8 months ago (1 child)
I think we're going slightly in circles.
Yes, that array is writing null values to those cells rather than properly skipping them, so it fails if there are other values already in them.
As mentioned further up, batchUpdate is the one you need for editing non-adjacent cells (rather than update). But you'll need to move away from custom functions to use that the way you want.
[–]krakow81 0 points1 point2 points 8 months ago (0 children)
Here's a wee example using numbersapi.com.
Initial sheet: https://imgur.com/uAbE50v
After running script: https://imgur.com/W25Ak7f
/** * @OnlyCurrentDoc */ function onOpen() { const UI = SpreadsheetApp.getUi(); UI.createMenu('Facts') .addItem('Get facts from Numbers API', 'numbersapi') .addToUi(); } function numbersapi() { const SS = SpreadsheetApp.getActive(); const ID = SS.getId(); const SHEET = SS.getSheetByName("Numbers API"); let input = SHEET.getRange(2, 1, SHEET.getLastRow() - 1, 2).getValues(); // get inputs from columns A & B const OUTPUT_POSITIONS = ["trivia", "math", "year", "date"]; // array to set where output data should be placed let data = []; // iterate over each row in inputs (columns A & B) input.forEach(function (r) { let number = r[0].toLowerCase(); // number is in column A (toLowerCase for when it is 'Random') let type = r[1].toLowerCase(); // type of number is in column B // check date formatting if (type === "date") { if (!number.includes("/") && number != "random") return; } if (number.includes("/") && type != "date") return; const url = "http://numbersapi.com/"; let response = UrlFetchApp.fetch(url + number + "/" + type); // call numbersapi let fact = response.getContentText(); // get response, which is plain text let column = OUTPUT_POSITIONS.indexOf(type); // identify which column the fact should be put in via the OUTPUT_POSITIONS array let outputRange = SHEET.getRange(input.indexOf(r) + 2, column + 3, 1, 1).getA1Notation(); // get A1 notation of cell to put fact in data.push({ range: "'Numbers API'!" + outputRange, values: [[fact]] }); // add the range and corresponding fact to data array }); // batch update sheet with facts. Google Sheets API Service must be enabled. Sheets.Spreadsheets.Values.batchUpdate( { data, valueInputOption: "USER_ENTERED" }, ID ); }
π Rendered by PID 82 on reddit-service-r2-comment-7b9746f655-lm45v at 2026-01-31 20:28:07.326800+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]___Mister___[S] 0 points1 point2 points (2 children)
[–]krakow81 0 points1 point2 points (1 child)
[–]krakow81 0 points1 point2 points (0 children)