P
P
PiShim2021-03-18 13:03:35
Google Sheets
PiShim, 2021-03-18 13:03:35

How to create a copy of a specific sheet in Google Sheets?

Good afternoon. There was a question about copying a certain sheet in the table. Wrote a small macro to create a duplicate, but the script copies the page that is active. Please tell me how to write a macro so that a certain page is copied, for example, only the first one. (macro attached to button)

function CopySheet() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('U472').activate();
spreadsheet.duplicateActiveSheet();
spreadsheet.moveActiveSheet(5);
spreadsheet.getActiveSheet().setName('Enter date');
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
datka, 2021-03-18
@datka

var spreadsheet = SpreadsheetApp.getActive();
Change to

var spreadsheet = SpreadsheetApp.getActive().getSheetByName('НазваниеЛиста');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question