google spreadsheet - How to Insert LastRow function and Text in If Statements in Script -


i have lengthy formula attempting set via script in particular cell in last row of specified column. formula:

sheet.getrange(lastrow+1,8).setformula("=if(and($s$2=1,f25/8=trunc(f25/8)),(((f25/8)+(g25/2))*3),if(and($s$2=1,(f25-6)/8=trunc((f25-6)/8)),((((f25-6)/8)+1+(g25/2))*3),if(and($s$2=1,(f25-12)/8=trunc((f25-12)/8)),((((f25-12)/8)+2+(g25/2))*3),if(and($s$2=1,(f25-18)/8=trunc((f25-18)/8)),((((f25-18)/8)+3+(g25/2))*3),if(and($s$2=0,f25/8=trunc(f25/8)),(((f25/8)+(g25/2))*5),if(and($s$2=0,(f25-6)/8=trunc((f25-6)/8)),((((f25-6)/8)+3+(g25/2))*5),if(and($s$2=0,(f25-12)/8=trunc((f25-12)/8)),((((f25-12)/8)+3+(g25/2))*5),if(and($s$2=0,(f25-18)/8=trunc((f25-18)/8)),((((f25-18)/8)+3+(g25/2))*5),0))))))))");  

i able able refer f25 , g25 refer f , g columns in last row such formula:

sheet.getrange("h" + (lastrow+1)).setformula("=e" + (lastrow+1) + "-(f" + (lastrow+1) + "*1.5)"); 

in ideal world able swap out $s$2=0 $s$2="full mastic" , check text rather value run issues when inserting additional parentheses required text function when formula inserted spreadsheet. help. know formula little ridiculous...

every time see 25 replace with: (including quotes)

" + (lastrow+1) + " 

for text items escape quotes preceding them backslash cause quotes inserted text instead of being interpreted text delimiter.

$s$2=\"full mastic\" 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -