简体   繁体   English

应用程序脚本 - 将一行数据从一个谷歌电子表格复制(仅值)到另一个(基于复选框)并将其从原始电子表格中删除

[英]App Scripts - Copy (values only) a row of data from one google spreadsheet to another (based on checked box) and deleting it from the original one

Data Source Spreadsheet = "https://docs.google.com/spreadsheets/d/1weqJpRcou0QWpekYg-eqBXUupqSoVC5w4Tc04sFTgWs/edit?usp=sharing"数据源电子表格 =“https://docs.google.com/spreadsheets/d/1weqJpRcou0QWpekYg-eqBXUupqSoVC5w4Tc04sFTgWs/edit?usp=sharing”

Data Destination Spreadsheet == "https://docs.google.com/spreadsheets/d/10Wa76S-slzmtCCePDChMJrLJYaAzA6H_NlpnJKWIfNU/edit?usp=sharing"数据目的地电子表格 == “https://docs.google.com/spreadsheets/d/10Wa76S-slzmtCCePDChMJrLJYaAzA6H_NlpnJKWIfNU/edit?usp=sharing”

function onEdit(e){
if(e.range.columnStart != 28 || e.value != "TRUE") return;
var sh = SpreadsheetApp.getActiveSpreadsheet();
var source = sh.getSheetByName("Sheet1");
var dest = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/10Wa76S-slzmtCCePDChMJrLJYaAzA6H_NlpnJKWIfNU/edit').getSheetByName("Completed");
dest.activate().getRange(dest.getLastRow()+1,1,1,25).setValues(source.getRange(e.range.rowStart,1,1,25).getValues());
source.deleteRow(e.range.rowStart);
}

I guessing that this is probably what you want:我猜这可能是你想要的:

function onMyEdit(e){
  const sh=e.range.getSheet();
  if(sh.getName()=='Sheet1' && e.range.columnStart == 28 && e.value == "TRUE") {
    const dsh=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/10Wa76S-slzmtCCePDChMJrLJYaAzA6H_NlpnJKWIfNU/edit').getSheetByName("Completed");
    dsh.getRange(dsh.getLastRow()+1,1,1,25).setValues(sh.getRange(e.range.rowStart,1,1,25).getValues());
    sh.deleteRow(e.range.rowStart);
  }
}

It needs to be an installable onedit trigger because it requires permission to move and delete data.它需要是一个可安装的 onedit 触发器,因为它需要移动和删除数据的权限。

Reference:参考:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google脚本会根据日期将范围从一个电子表格复制到另一个电子表格 - Google scripts copy range from one spreadsheet to another based on date 将一行从一个Google表格电子表格复制到表单提交中的另一表格 - Copy a row from one Google Sheet Spreadsheet to Another on Form Submit 仅将活动行从一个电子表格复制到另一个电子表格 - Copy only active row from one spreadsheet to another 将过滤后的范围从一个电子表格复制到另一个 - Google 应用脚本 - Copy filtered range from one spreadsheet to another - Google app script 如何使用谷歌应用脚本将一行从一个谷歌电子表格复制到另一个谷歌电子表格? - How to copy a row from one google spreadsheet to another google spreadsheet using google apps script? 在 Google Scripts 中将值从一列复制到另一列 - Copy Values from One Column to Another in Google Scripts Google Apps 脚本 - 将一行数据从一个电子表格移动到另一个电子表格 - Google Apps Script - move a row of data from one spreadsheet to another Google App Script - 如何将数据范围的粘贴值(仅非空单元格)从电子表格复制到另一个电子表格 - Google App Script - how to Copy Paste values ( only non empty cells) of a data range with , from a Spreadsheet to another Spreadsheet 在编辑时将数据从一个电子表格复制到另一个电子表格 - Copy data from one spreadsheet to another on edit Google Spreadsheet-脚本,每天在特定时间将单元格从一张工作表复制到另一张工作表 - Google Spreadsheet - Scripts, copy cell from one sheet to another sheet EVERYDAY at a specific time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM