B
B
bulkmaker2019-07-03 09:26:26
Google Sheets
bulkmaker, 2019-07-03 09:26:26

How to insert cells from another page and edit them in Google Sheets?

I have several pages in the book. I need the first column from the first page to be visible on each page with formatting. You also need to be able to edit this column from any page. How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2019-07-15
@ProgrammerForever

Use the onEdit(event) function to track changes. Each time you change the first column - copy the entire column to all other sheets. Fires only on value changes, not on formatting changes.

function onEdit(event){  
  ss=SpreadsheetApp.getActiveSpreadsheet();//Текущая книга
  if (event.source.getActiveRange().getColumn()===1){//Если столбец №1
    ss.getSheets().forEach(function(sheet){//Перебираем все листы
      if (event.source.getActiveSheet().getName()!=sheet.getName()){//Если это другой лист
        event.source.getActiveSheet().getRange('A:A').copyTo(sheet.getRange('A:A'), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);//Копируем 1й столбец
      };      
    });
  };
};

To make it work, you need to give the script permission to edit. You can just force it to be called from the script editor the first time

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question