G
G
gray300919852020-12-18 15:03:47
Google Sheets
gray30091985, 2020-12-18 15:03:47

Executing a macro in a selected cell?

function f1(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Главная");
if(sheet.getRange(4, 5).isChecked()===true){
var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Билеты'), true);
  spreadsheet.getRange('C3').activate();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Главная'), true);
  spreadsheet.getRange('\'Билеты\'!C3').copyTo(spreadsheet.getActiveCell(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
}}


Please tell me how to make the macro run in any selected active cell. Currently only A1 is running

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2020-12-18
@grey30091985

You have it first , and then I can’t understand what is being done at all, but I think that you need to remember the active cell in advance
spreadsheet.getRange('C3').activate();
spreadsheet.getActiveCell()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question