0

This is a really dumb question. I have a list of information in column A. I want to run that information through an API and return the result in column B. After I query an API, I understand how to return the values at the bottom of the spreadsheet appendrow(). If however I want to return the results, say starting in column B, row 1 so that the results line up with the cell I am running the API on, how do I do that?

Rubén
  • 34,714
  • 9
  • 70
  • 166
Dan Voell
  • 13
  • 4
  • I followed this question -https://stackoverflow.com/questions/15616530/how-to-loop-range-of-cells-and-set-value-in-adjacent-column I was able to get the first part (question) with a single value working but the answer (with a range) through an error for me. – Dan Voell Aug 11 '17 at 15:52

1 Answers1

1

1) Define the range that your values will go into.

var range = sheet.getRange(1, 2, sheet.getLastRow(), 1);

By using this notation, you tell the range to start at B1 (1st row, 2nd column), span as many rows as the sheet has and exactly 1 column.

2) Call the setValues() method on the range to insert values.

range.setValues(yourValues);

Note that you need a nested array for each row in 'yourValues'

[
  [col1, col2], //row 1
  [col1, col2] //row 2
]
Anton Dementiev
  • 5,451
  • 4
  • 20
  • 32