简体   繁体   中英

Copy values of multiple cells on form submit into a single cell in a different Google Sheet

I'm trying to grab multiple cells from the last row of a Google Sheet upon a form submittal and copy them to a single cell in different sheet.

How do I combine the values in this array into one value? I'd like to put a comma and space between the data.

 var daterange = sourcesheet.getRange("H"+source_last_row+":Q"+source_last_row);

I'm not even sure the query is correct. The Logger says "Range". :\\

I am grabbing the values below this in the script.

 var source_range6_values = daterange.getValues();

Logger returns "Range" because your variable is just a range. To get an array of the values in that range, you need to use the .getValues() method.

var daterange = sourcesheet.getRange("H"+source_last_row+":Q"+source_last_row);
var daterangeVals = daterange.getValues();

You can then use the .toString() method to convert the array to string.

That will return the values separated by a comma. As you want a comma and a space, you could then use the .replace() method on the string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM