简体   繁体   中英

Copy Data from one sheet to another - Google Script

I'm trying to run a code that lets me copy the value of any single cell in one sheet and then paste it into a specific cell in another sheet, however I've been getting errors saying "Range not found".

function Find() {
  var spreadsheet = SpreadsheetApp.getActive();
  var currcell = spreadsheet.getCurrentCell();
  spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Exp GPPB Breakdown'), true);
  spreadsheet.getRange('C1').activate();
  spreadsheet.getRange(currcell).copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  spreadsheet.getRange('A4').activate();
  var criteria = SpreadsheetApp.newFilterCriteria()
  .build();
  spreadsheet.getActiveSheet().getFilter().setColumnFilterCriteria(1, criteria);
};

Replace

var currcell = spreadsheet.getCurrentCell();

with

var currcell = spreadsheet.getActiveSheet().getCurrentCell().getA1Notation();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM