'Can I import range data from particular range of Sheet 1 to Sheet 2?

function importdata() {
var ss = SpreadsheetApp.openById("1ZMEyhD_3qTZk0ccAs82uWPpjkfvMKjywr-DyjNUAOMQ");
var source = ss.getSheetByName("Data base");
var rangeSource = source.getDataRange();
var data = rangeSource.getValues();
var lr = rangeSource.getLastRow();
var lc = rangeSource.getLastColumn();
Logger.log(data);
var sss = SpreadsheetApp.openById("1rxRVBhHnRB3kw9zCmJj3U3mSN3hEvJlnllgrncEzEWk");
var target = sss.getSheetByName("sheet1")
target.getRange(target.getLastRow()+2,1,lr,lc).setValues(data);  // input target row number  , column number
} 

I have got the function mentioned above from stackoverflow. This app script mentions where to copy in target sheet. But this function copies all data from sheet 1 (source sheet) ( All range right from the first cell in the source sheet).

I Would like to copy from particular range from source sheet (sheet1). (From A72 to Z100)

My heart thanks to stackoverflow for giving opportunity to learn....



Solution 1:[1]

function getdata() {

  //Copies source range to specific destination range( But overwrites, rather than copy down into a new row.)  

 // source sheet
var sourcess = SpreadsheetApp.openById("1BxJl0UHy-wmKO0eln4EIDGYxfMhNNFNi8FBvEmxkmaA");   // source sheet id 
var sourcesheet = sourcess.getSheetByName('Data base'); // source sheet name
var sourcerange = sourcesheet.getRange('A72:Z100');  // source sheet range ( where from copy)
var sourcevalues = sourcerange.getValues();

 // destination sheet
 var ss = SpreadsheetApp.getActiveSpreadsheet(); 
var destsheet = ss.getSheetByName('Sheet1');  // destination sheet name
var destrange = destsheet.getRange('A1:Z29'); // destination sheet range ( where to paste )
destrange.setValues(sourcevalues);  
}\

As usual i found this script from stackoverflow...Thank you....

Solution 2:[2]

Use:

target.getRange(A72:Z100); 

to get the range.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Elango nithyanandam
Solution 2 General Grievance