Home > Software design >  The sheet don´t get active
The sheet don´t get active

Time:03-02

The problem is that the sheet where I want to enter de value doesn´t get active so the value enter in the same sheet where it is

I think the problem is in the line 8, because with out them the sheet get active. But I don´t kwon why

function Pago(){
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getActiveSheet();
 var row = ss.getRange('\'Entradas\'!B5').getRow();
 var ce =ss.getRange('\'Entradas\'!B3').getValue();
 var rowi = ce row
 var code = ss.getRange('b5').getValue();
 ss.setActiveSheet(ss.getSheetByName('Entradas'));
 sheet.getRange(rowi, 2).activate();
 ss.getActiveRange().setValue(code);
}

CodePudding user response:

I think this is want you want

function Pago(){
 var ss = SpreadsheetApp.getActive();
 var sheet = ss.getActiveSheet();
 const sh = ss.getSheetByName('Entradas');
 var row = ss.getRange('\'Entradas\'!B5').getRow();
 var ce =ss.getRange('\'Entradas\'!B3').getValue();
 var rowi = ce row;
 var code = sheet.getRange('b5').getValue();
 sh.getRange(rowi,2).setValue(code);
}
  • Related