Answer the question
In order to leave comments, you need to log in
Copy data from one sheet of a table to another table per sheet to the last empty row?
Hello, please tell me how to make it copied from a table to a table, for example, from the "Employee1" table, to the "Data" table, this is possible, thank you for your help, that is, if a person has access only to the "Employee1" table, but there will be no access to the "Data" table, will the script work in this case? Here is the code that copies from sheet to sheet.
/**
*
*/
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Custom menu')
.addItem('Copy to logs', 'userActionsCopyToLogs')
.addToUi();
}
/**
*
*/
function userActionsCopyToLogs() {
var headers = ['Name', 'Number'];
var from = SpreadsheetApp.getActiveSheet();
if (from.getName() !== 'Sheet1') {
SpreadsheetApp.getActive().toast('Activate a range on "Sheet1"');
return;
}
var fromValues = from.getDataRange().getValues();
var fromHeaders = fromValues[0].map(function(h) {
return headers.indexOf(h);
});
var activeRange = SpreadsheetApp.getActiveRange();
var rowStart = activeRange.getRow();
var rowEnd = activeRange.getLastRow();
var fromData = fromValues
.filter(function(row, i) {
return i >= rowStart - 1 && i <= rowEnd - 1;
})
.map(function(row) {
return row.filter(function(_, j) {
return fromHeaders[j] > -1;
});
});
var to =
SpreadsheetApp.getActive().getSheetByName('Logs') ||
SpreadsheetApp.getActive().insertSheet('Logs');
to.getRange(to.getLastRow() + 1, 1, fromData.length, fromData[0].length)
.setValues(fromData)
.activate();
}
Answer the question
In order to leave comments, you need to log in
Unfortunately, most likely an accurate answer with a solution to such a question is beyond the scope of public support. But no one cancels the theory.
In this case, you need to create two scripts:
There are other reliable hacks that work without the user even knowing about them.
In any case, dig towards Google Apps Script Web Apps. This should help. You don't need any deprivation of code, except for sending a request to the server and receiving data on the server. Everything else is already there.
Sincerely.
if a person has access only to the "Employee1" table, and no access to the "Data" table, will the script work in this case?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question