Google Sheets Script =SyntaxError: missing ) after argument list (line 19, file "Reset.gs")

yvettew78

New Member
Joined
Aug 23, 2020
Messages
34
Platform
  1. Windows
  2. Web
Can anyone please help me with the following error.


var cell = sheet.getRange("E44");
cell.setFormula("=IF(AND(E3="Cash",E4="Residential",E5="Single"),VLOOKUP(C10,'RRP Pricing'!A2:G58,2,FALSE),IF(AND(E3="Cash",E4="Residential",E5="three"),VLOOKUP(C10,'RRP Pricing'!A2:G58,2,FALSE),IF(AND(E3="Cash",E4="Residential",E5="three"),VLOOKUP(C10,'RRP Pricing'!A2:G58,3,FALSE),IF(AND(E3="Cash",E4="Commercial",E5="three"),VLOOKUP(C10,'RRP Pricing'!A2:G58,4,FALSE),IF(AND(E3="Finance",E4="Residential",E5="Single"),VLOOKUP(C10,'RRP Pricing'!A2:G58,5,FALSE),IF(AND(E3="Finance",E4="Residential",E5="Three"),VLOOKUP(C10,'RRP Pricing'!A2:G58,6,FALSE),IF(AND(E3="Finance",E4="Commercial",E5="Three"),VLOOKUP(C10,'RRP Pricing'!A2:G58,7,FALSE),0)');

For some reason it comes up with an error when I use it in the script I am creating,
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You start with a double quote but end with a single quote, try enclosing the entire formula in single quotes.

Also, you need to escape the single quotes around the sheet name.

This code will work but there still appears to be a problem with the formula and I can't quite figure out what.
VBA Code:
  var cell = sheet.getRange("E44");
  cell.setFormula('=IF(AND(E3="Cash",E4="Residential",E5="Single"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,2,FALSE),' +
                  'IF(AND(E3="Cash",E4="Residential",E5="three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,2,FALSE),' +
                  'IF(AND(E3="Cash",E4="Residential",E5="three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,3,FALSE),' +
                  'IF(AND(E3="Cash",E4="Commercial",E5="three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,4,FALSE),' +
                  'IF(AND(E3="Finance",E4="Residential",E5="Single"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,5,FALSE),' + 
                  'IF(AND(E3="Finance",E4="Residential",E5="Three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,6,FALSE),' +
                  'IF(AND(E3="Finance",E4="Commercial",E5="Three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,7,FALSE),0)');
 
Upvote 0
You start with a double quote but end with a single quote, try enclosing the entire formula in single quotes.

Also, you need to escape the single quotes around the sheet name.

This code will work but there still appears to be a problem with the formula and I can't quite figure out what.
VBA Code:
  var cell = sheet.getRange("E44");
  cell.setFormula('=IF(AND(E3="Cash",E4="Residential",E5="Single"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,2,FALSE),' +
                  'IF(AND(E3="Cash",E4="Residential",E5="three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,2,FALSE),' +
                  'IF(AND(E3="Cash",E4="Residential",E5="three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,3,FALSE),' +
                  'IF(AND(E3="Cash",E4="Commercial",E5="three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,4,FALSE),' +
                  'IF(AND(E3="Finance",E4="Residential",E5="Single"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,5,FALSE),' +
                  'IF(AND(E3="Finance",E4="Residential",E5="Three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,6,FALSE),' +
                  'IF(AND(E3="Finance",E4="Commercial",E5="Three"),VLOOKUP(C10,\'RRP Pricing\'!A2:G58,7,FALSE),0)');
Thank you for your reply.

The code worked but when I run the script Cell E44 comes up with a formulas parse error but if I double click on the cell and press enter, it fixes itself and the error disappears. Any idea why this is happening?
 
Upvote 0

Forum statistics

Threads
1,223,636
Messages
6,173,484
Members
452,516
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top