Answer the question
In order to leave comments, you need to log in
How to automatically create a copy of a spreadsheet sheet?
Good afternoon!
Please help me write a script for google sheets.
The bottom line is that there is an initial sheet that is filled out daily and printed out.
It is necessary to make it so that when filling in the first (template) sheet of the table, a separate copy sheet is displayed by clicking the button.
Thus, 30-31 sheets with data should be created in the new file per month.
Answer the question
In order to leave comments, you need to log in
You will need Google Apps Script to run the program from the Tables menu.
Create a menu
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Reset sheet')
.addItem('Make a copy before reset', 'userActionMakeCopyBeforeReset')
.addToUi();
}
function userActionMakeCopyBeforeReset() {
const book = SpreadsheetApp.getActive();
const sheet = book.getActiveSheet();
makeCopyBeforeReset_(sheet, book);
}
function makeCopyBeforeReset_(sheet, book) {
const copy = sheet.copyTo(book);
const rangesAddressesList = ['B5', 'B7', 'B9', 'B11'];
resetByRangesList_(sheet, rangesAddressesList);
return copy;
}
function resetByRangesList_(sheet, rangesAddressesList) {
sheet.getRangeList(rangesAddressesList).clearContent();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question