简体   繁体   English

通过按钮将值从Google电子表格中的特定单元格复制到另一个单元格

[英]Copy value from specific cell in google spreadsheet to another via button

On the click on a Button I want a function to be triggered that copies the value from Sheet1!A6 to Sheet2!A6 . 在单击按钮时,我希望触发一个将值从Sheet1!A6复制到Sheet2!A6的函数。 (see template) ! (请参见模板) What do I have to add to this to make it work? 我必须添加什么才能使其正常运行?

function CopyPasteA6() {
   var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');            

   sheet.getRange('A6').value
    ???
}

Thanks for help! 感谢帮助!

try like this, it's probably the simplest way to do it. 尝试这样,这可能是最简单的方法。

function CopyPasteA6() {
   var sheet1 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');            
   var sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');            
   sheet1.getRange('A6').copyTo(sheet2.getRange('A6'))
}

then insert a drawing or an image in your sheet and assign the function to this image. 然后在图纸中插入图形或图像,然后将功能分配给该图像。

在此处输入图片说明

EDIT following your comment : this script copies to the next sheet if it exist. 在您的评论之后进行编辑:如果存在,此脚本将复制到下一张工作表。 you'll have to put a button on each sheet though.... I'd suggest to use a menu instead that will be acessible from anywhere in the spreadsheet. 但是,您必须在每个工作表上放置一个按钮。...我建议您使用菜单,而该菜单可以在电子表格的任何位置使用。

Note that 'A6' or "A6" are just the same ;-) 请注意,“ A6”或“ A6”是相同的;-)

function CopyPasteA6() {
   var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
   var sheetidx = sheet.getIndex()-1 ;
   var nextSheet = SpreadsheetApp.getActiveSpreadsheet().getSheets()[sheetidx+1];

   sheet.getRange('A6').copyTo(nextSheet.getRange('A6'))
}

暂无
暂无

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

相关问题 通过脚本(谷歌表格)复制单元格值并将其发送到另一个电子表格的更快方法 - Faster way to copy a cell value and send it to another spreadsheet via script (Google Sheets) Google Spreadsheet-脚本,每天在特定时间将单元格从一张工作表复制到另一张工作表 - Google Spreadsheet - Scripts, copy cell from one sheet to another sheet EVERYDAY at a specific time 如何制作一个按钮以跳到Google Spreadsheet中另一个工作表中的特定单元格? - How to make a button to jump to a specific cell in another sheet in Google Spreadsheet? 如何使用Google Apps脚本将特定的行从3个Google电子表格复制到另一个电子表格 - How to copy specific rows from 3 google spreadsheet to another spreadsheet using google apps script Google Spreadsheet-如何将单元格数据从一张工作表复制到另一张工作表中的单元格? - Google Spreadsheet - How to copy cell data from one sheet to a cell in another sheet? 在 Google 电子表格脚本中获取特定单元格值 - Get a specific cell value in a Google Spreadsheet Script 根据单元格中的值将行的一部分从一个 Google 电子表格复制到另一个 Google 电子表格? - Copying part of a row from one Google spreadsheet to another google spreadsheet based on a value in a cell? Google电子表格脚本 - 将值移至特定单元格 - Google spreadsheet script - move value to specific cell 如果单元格值大于0,则禁用按钮 - disable button if cell value is > 0 google spreadsheet CopyTo:如何使用Google Apps脚本将数据从一个Google电子表格推入/复制单元格到另一个Google电子表格? - CopyTo: How to push data/copy a cell from one google spreadsheet to another google spreadsheet using google apps script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM