문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top