[Solved] How to write a particular formula in form of google script code


????

I tried to figure out what your doing but I couldn’t get all of it. You have a lot of things wrong. Have you tried any examples in the documentation? That might be a good starting point for you.

I think this is close to what you want but I’m not sure what you wish to do once you satisfy the conditions because what your doing makes no sense to me.

function FilterRng(){
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getSheetByName("Data");
  var cond1=ss.getSheetByName('Bookings').getRange('E12').getValue() - 14;
  var cond2=ss.getSheetByName('Bookings').getRange('BH12').getValue() + 14;
  var valA1=sh.getRange('D9:D32').getValues();
  var valA2=sh.getRange('F9:F32').getValues();
  for(var i=0;i<valA1.length;i++){
    if(valA1[i][0]>=cond1 && valA2[i][0]<=cond2){
      //you want to do something but I'm not sure what  
      //perhaps sh.getRange('Some Cell').setFormula('some cell formula')
    }
  }
}

2

solved How to write a particular formula in form of google script code