Answer the question
In order to leave comments, you need to log in
How to copy a page to the left, to the right of a template with a script in Google sheets?
When the button is pressed, the page is copied using the script:
sheet2 = sheet.copyTo(ss).setName(sheet2.getResponseText());
Answer the question
In order to leave comments, you need to log in
Sheets do not move in the Table. They need to be activated.
{
const sheet2 = sheet.copyTo(ss).setName(sheet2.getResponseText());
sheet2.activate();
ss.moveActiveSheet(1);
}
function muFunction() {
const ui = SpreadsheetApp.getUi();
const book = SpreadsheetApp.getActiveSpreadsheet();
const sheet = book.getSheetByName('Шаблон');
const prompt = ui.prompt('New Sheet Name?');
if (prompt.getResponseText()) {
const copy = sheet.copyTo(book).setName(prompt.getResponseText());
copy.activate();
book.moveActiveSheet(sheet.getIndex());
}
}
book.moveActiveSheet(sheet.getIndex()+1);
function copyTo() {
let ss = SpreadsheetApp.getActiveSpreadsheet();
let ws = ss.getActiveSheet();
// по умолчанию копирует справа от активного листа, при -1 слева.
ss.insertSheet("Тест", ws.getIndex());
// ss.insertSheet("Тест", ws.getIndex() - 1);
SpreadsheetApp.flush();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question