0

I am filling an array with some formulas to write as part of a data moving script. This line throws "unexpected string" error from Google Script when I try to save it:

var forms = [[,"=\"Week Averages\"","=iferror(round(average(C"+startRow+":C"+endRow+"),1),)",,,,,,,
"=rept(char(9733),(round(arrayformula(sum(len(J"+startRow+":J"+endRow+")-len(SUBSTITUTE(J"+startRow+":J"+endRow+",char(9733),""))))/counta(J"+startRow+":J"+endRow+"))))&rept(char(9734),5-(round(arrayformula(sum(len(J"+startRow+":J"+endRow+")-len(SUBSTITUTE(J"+startRow+":J"+endRow+",char(9733),""))))/counta(J"+startRow+":J"+endRow+"))))",
"=rept(char(9733),(round(arrayformula(sum(len(K"+startRow+":K"+endRow+")-len(SUBSTITUTE(K"+startRow+":K"+endRow+",char(9733),""))))/counta(K"+startRow+":K"+endRow+"))))&rept(char(9734),5-(round(arrayformula(sum(len(K"+startRow+":K"+endRow+")-len(SUBSTITUTE(K"+startRow+":K"+endRow+",char(9733),""))))/counta(K"+startRow+":K"+endRow+"))))",
"=rept(char(9733),(round(arrayformula(sum(len(L"+startRow+":L"+endRow+")-len(SUBSTITUTE(L"+startRow+":L"+endRow+",char(9733),""))))/counta(L"+startRow+":L"+endRow+"))))&rept(char(9734),5-(round(arrayformula(sum(len(L"+startRow+":L"+endRow+")-len(SUBSTITUTE(L"+startRow+":L"+endRow+",char(9733),""))))/counta(L"+startRow+":L"+endRow+"))))",
"=rept(char(9733),(round(arrayformula(sum(len(M"+startRow+":M"+endRow+")-len(SUBSTITUTE(M"+startRow+":M"+endRow+",char(9733),""))))/counta(M"+startRow+":M"+endRow+"))))&rept(char(9734),5-(round(arrayformula(sum(len(M"+startRow+":M"+endRow+")-len(SUBSTITUTE(M"+startRow+":M"+endRow+",char(9733),""))))/counta(M"+startRow+":M"+endRow+"))))",
"=countif(N"+startRow+":N"+endRow+",\"=Yes\")/(countif(N"+startRow+":N"+endRow+",\"=Yes\")+countif(N"+startRow+":N"+endRow+",\"=No\"))",,,,,,,,]]

Can anyone help me see what I'm missing? I've tried removing different sections of it and can't seem to pinpoint the problem. Thank you!

1 Answer 1

1

You're getting an error because of the quotation marks "". You can:

  • escape the marks \"\"
  • use single quotes ' to delineate your strings endRow+',char(9733),""))))/counta(J'+startRow
  • use template literals (e.g. `${endRow},char(9733),""))))/counta(J${startRow}`)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.