简体   繁体   中英

Copy a range from one sheet to another in google sheet

I ave been trying to copy a range from one google sheet to another without success. I have tried all the answers that I have come accross but they were al fruitless for me. Everything in the script work apart from the content or ell does not get copied.

Any help or guidance will be very much appreciated. Here is the code that I am using:

function copyCell() {



var ss = SpreadsheetApp.getActiveSpreadsheet();

  var source = ss.getSheetByName("City");

  var destination = ss.getSheetByName("Boost");


  var source_range = source.getRange("A17").getValue(); 

  ss.setActiveSheet(ss.getSheets()[2]);

  destination.insertRowAfter("3");

  var destination_range = destination.getRange("A4")

  destination_range.setValue(source_range);

  Browser.msgBox("The value has been added",Browser.Buttons.OK)

}

My friend I created this script and works fine for me

Function copyCell (sourceWorksheet, sourceSpreadsheet, rangeToCopy, destSpreadsheet, destRow, destColumn) {
 var source = SpreadsheetApp.openById(sourceWorksheet);
 var sourceSheet = source.getSheetByName(sourceSpreadsheet);
 var destSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(destSpreadsheet);

var rangoToCopy = sourceSheet.getRange(rangeToCopy).getValue;

destSheet.getRange(destRow,destColumn).setValue(rangoToCopy)}

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