[英]Copy Paste to another sheet
I've been using Excel for the longest time but would now need to use Google sheet for the new company that I work for.我使用 Excel 的时间最长,但现在需要为我工作的新公司使用 Google 表格。 Seems like it is harder than I expected.
好像比我预想的要难。
I am creating a form to track how long an employee finishes a certain task for a client.我正在创建一个表单来跟踪员工为客户完成某项任务的时间。
A simple form that I created where I hide the details on Form:F1,J1 (F1 - Time now, G1 - Name of employee, H1 - Client name, I1 - task done and J1 - Start/End the task我创建的一个简单表单,我在其中隐藏了表单的详细信息:F1,J1(F1 - 现在时间,G1 - 员工姓名,H1 - 客户姓名,I1 - 完成任务和 J1 - 开始/结束任务
I just want to copy and paste the values to the next empty row on the Tracker sheet.我只想将值复制并粘贴到 Tracker 表上的下一个空行。
I tried to search previous answers but doesn't seem to work.我试图搜索以前的答案,但似乎没有用。 I always get an error message:
我总是收到一条错误消息:
"ReferenceError: database is not defined"
“ReferenceError:未定义数据库”
on the var copyToSheet = database.getSheetByName('Tracker;A1');
在
var copyToSheet = database.getSheetByName('Tracker;A1');
part.部分。 Here's what I got.
这就是我得到的。
function Done() {
var ss = SpreadsheetApp.getActiveSpreadsheet()
var source = ss.getSheetByName('Form');
var dataToCopy = source.getRange('F1:J1');
var copyToSheet = database.getSheetByName('Tracker!A1');
var sourceValues = dataToCopy.getValues();
var lastRow = copyToSheet.getLastRow();
copyToSheet.getRange(lastRow + 1, 1, sourceValues.length, sourceValues[0].length).setValues(sourceValues);
dataToCopy.clear({
contentsOnly: true
});
}
I was able to find the correct code somewhere and just changed it a bit.我能够在某处找到正确的代码,并对其进行了一些更改。
function Done() { var ss = SpreadsheetApp.getActiveSpreadsheet();
function Done() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var copySheet = ss.getSheetByName("Form");
var copySheet = ss.getSheetByName("Form"); var pasteSheet = ss.getSheetByName("Tracker");
var pasteSheet = ss.getSheetByName("Tracker");
var source = copySheet.getRange(1,6,1,5);
var source = copySheet.getRange(1,6,1,5); //from which row number, from which column number, 1, how many cells to copy var destination = pasteSheet.getRange(pasteSheet.getLastRow()+1,1,1,5);
//从哪个行号,从哪个列号,1,复制多少个单元格 var destination = pasteSheet.getRange(pasteSheet.getLastRow()+1,1,1,5); source.copyTo(destination,{contentsOnly:true});
source.copyTo(destination,{contentsOnly:true});
//this is to delete what you input on the form after it copies and pastes to the tracker //这是在复制并粘贴到跟踪器后删除您在表单上输入的内容
var ss = SpreadsheetApp.getActive().getSheetByName("Form");
var ss = SpreadsheetApp.getActive().getSheetByName("Form"); var cell = ss.getRange("C4:C7");
var cell = ss.getRange("C4:C7"); cell.clearContent();
单元格.clearContent();
};
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.