简体   繁体   English

Select 单元格(Ctrl+A)然后复制范围并粘贴到另一个工作表的第一个空行

[英]Select cells(Ctrl+A) then Copy range and paste to another sheet's first empty row

I would like to copy a range from a sheet to another sheet's first empty row.我想将一个范围从一张纸复制到另一张纸的第一个空行。 But instead of copying the whole spreadseet i want to select the cells (like i do with CTRL+ A) and only the selected(ctrl+A) cells should be copied to another sheet's first row.但是,我不想复制整个电子表格,而是要 select 单元格(就像我使用 CTRL+A 所做的那样)并且只有选定的(ctrl+A)单元格应该被复制到另一张工作表的第一行。 Here is a script that i found here in stackoverflow and it works but it only copy that range i give for example: sheet1:F1.H3.这是我在stackoverflow中找到的一个脚本,它可以工作,但它只复制我给出的范围,例如:sheet1:F1.H3。 I want the script to find the cells like ctrl+ A does and then it copies to the other sheet's first empty row.我希望脚本像 ctrl+ A 那样找到单元格,然后将其复制到另一张工作表的第一个空行。

Thank you so much for your help in advance.非常感谢您提前提供的帮助。

Here is the script:这是脚本:

function moveValuesOnly () {
  var ss = SpreadsheetApp.getActiveSpreadsheet ();
  var source = ss.getRange ("Sheet1!F1:H3");
  var destSheet = ss.getSheetByName("Sheet2");
  // Déterminer l'emplacement de la première ligne vide.
  var destRange = destSheet.getRange(destSheet.getLastRow()+1,1);`enter code here`
  source.copyTo (destRange, {contentsOnly: true});
  source.clear ();
}

Using getDataRange() solved the issue.使用getDataRange()解决了这个问题。

As mentioned in the documentation:如文档中所述:

Returns a Range corresponding to the dimensions in which data is present.返回与存在数据的维度相对应的范围。

暂无
暂无

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

相关问题 将特定范围复制到从一个工作表到另一个工作表中的第一个空行和特定列 - Copy a specific range to from one sheet to the first empty row and specific column in another sheet 从范围复制单元格值并将其粘贴到另一个工作表的单行中 - To copy Cell values from a range and paste it in a single row of another sheet Google Apps 脚本 - 尝试有效地将不连续的单元格从一张纸复制到另一张纸的第一个空行 - Google Apps Script- Trying to Efficiently Copy Noncontiguous Cells From One Sheet to a First Empty Row of Another 将粘贴复制到另一张纸并找到没有空行的最后一行 - Copy paste to another sheet and find last row without empty rows 将单元格范围复制到另一个工作表 - Copy range of cells to another sheet 将活动行复制到另一个工作表,最后一行第一个空单元格 - Copy active row to another sheet with last row first empty cell 从母版工作表的最后一行复制数据,并将其粘贴到Google工作表中另一工作表的特定单元格 - Copy data from last row of master sheet and paste it in specific cells in another sheet in google sheets Google Sheets 将行复制并粘贴到另一个工作表中,然后从第一个工作表中删除内容 - Google Sheets copy and paste row into another sheet and then delete content from the first sheet 如果满足条件,我需要帮助将行中的某些单元格复制并粘贴到另一个工作表 - I need help to Copy and Paste certain cells in a row to another sheet if criteria is met 复制一个范围并仅将具有值和图像的行粘贴到另一个工作表中下一个空白行的谷歌工作表中? - Copy a range and paste only rows with values & images into another sheet at the next blank row in the google sheets?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM