Reputation: 359
I am looking for some help on modifying an equation so that it works inside appsscript code.
Formula in GoogleSheets:
=IF(HOME!T2:T<>"",TRANSPOSE(IMPORTXML(LEFT(HOME!T2:T,FIND("#",SUBSTITUTE(HOME!T2:T,"/","#",4))-1),"//strong[@data-e2e='video-views']")),"")
Line in AppsScript:
cell.setFormula("=IF(HOME!T2:T<>'',TRANSPOSE(IMPORTXML(LEFT(HOME!T2:T,FIND("#",SUBSTITUTE(HOME!T2:T,'/','#',4))-1),'//strong[@data-e2e='video-views']')),'')");
Appreciate any help I can get with this!
Upvotes: 0
Views: 54
Reputation: 359
Sorry, maybe my brain was just not functioning correctly. I have escaped the quotation marks within the String and hopefully it should work now:
cell.setFormula("=IF(HOME!T2:T<>\"\",TRANSPOSE(IMPORTXML(LEFT(HOME!T2:T,FIND(\"#\",SUBSTITUTE(HOME!T2:T,\"/\",\"#\",4))-1),\"//strong[@data-e2e='video-views']\")),\"\")");
Upvotes: 1