Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

google apps script - .setFormula() and received error missing ) argument list

I have .setFormula() and stuck on this. I think the problem is the comma (&","). I have researched several online forum before posting this question but no luck; perhaps someone here could help me out. I do know the rules about using the "" and '' that's why I have tried several formulas but still, I receive the error message:

"Missing ) after argument list".

Your time and help is appreciated!

Original formula:

=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>"")&", "))

code:

me.getRange('B8').setFormula("=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>"") & ", "))");

Formulas I have tried but failed:

"=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>'') & ', '))");
'=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>'') & ', '))');
"=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>'') & ", "))");
'=arrayformula(concatenate(filter("Sheet1"!E2:E,"Sheet1"!E2:E<>"") & ", "))'); 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You dont need single quotes ' around Sheet1.

Try

me.getRange('B8')
    .setFormula('=arrayformula(concatenate(filter(Sheet1!E2:E,Sheet1!E2:E<>"") & ", "))"');

If you still need it, you need to escape it with backlashes like this ':

me.getRange('B8')
    .setFormula('=arrayformula(concatenate(filter('Sheet1'!E2:E,'Sheet1'!E2:E<>"") & ", "))"');

Reference:

String § Escape notation


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...