Reputation: 28030
I am using Google Sheets and writing a custom function that takes in a range of cells as parameter and returns a string that adds a delimiting comma to the contents of the cell.
For example, we have a range B1:B2
where cell B1 contains "B1_contents"
and cell B2 contains "B2_contents"
. The function should return "B1_contents, B2_contents"
.
How can this be done in Google Sheets using Google Apps Script?
Upvotes: 0
Views: 3271
Reputation: 16551
You can try the following:
function rangeToStringSep(range, sep) {
return range.toString().split(',').join(sep);
}
Use:
=rangeToStringSep(B1:B3; ", ")
UPDATE
function rangeToStringSep1(range, sep) {
return range.join(sep);
}
Upvotes: 2
Reputation: 46792
have you tried something like that ?
function toCommaSepStrings(values){
return values.toString();
}
Upvotes: 1