sheet.getrange.setvalue doesn't put expected data into Google Sheet

1,348 views
Skip to first unread message

tooli...@gmail.com

unread,
Jun 29, 2017, 4:36:53 PM6/29/17
to AdWords Scripts Forum
Hi,

I'm new to AdWords scripts and currently trying to transfer data from my Shopping feed into a Spreadsheet automatically.

I succeeded in putting the required data into an Array, set up somewhat like this:

data[0][0] = "10001"; (article number / identifier)
data[0][1] = "some product label";
data[1][0] = "10002";
data[1][1] = "some other product label";
...and so on

Now I tried this:

sheet.getRange(1, 1, numberOfProducts, 2).setValue(data); // meaning to put beginning at field A1 into a number of rows equal to number of products, and into 2 columns, the data from the constructed array

But instead of seeing a sheet like this:

10001 | some product label
10002 | some other product label

All I get is this:

10001 | 10001
10001 | 10001

What am I doing wrong here?

Thanks in advance for the help!

Roy Steves

unread,
Jun 29, 2017, 6:04:19 PM6/29/17
to AdWords Scripts Forum
I think you're looking for .setValues(), with the 's'.  

Section: "Set a range's values".

The singular version is for setting a single cell, which is applying the update as if it were a static value, not an array, hence the output.

Vincent Racaza (AdWords Scripts Team)

unread,
Jun 30, 2017, 1:34:23 AM6/30/17
to AdWords Scripts Forum
Thanks Roy for your answer!

Hi Heiner,

Roy is correct. Please use the setValues() function to set an array of values in your defined ranges in your spreadsheet.

Let me know if this helps.

Thanks,
Vincent Racaza
AdWords Scripts Team
Reply all
Reply to author
Forward
0 new messages