I’m working on a Google Sheets project where I need to move a block of data from one worksheet to another using a script. The source data is located in cells G10 through J11 on the first sheet (that’s 4 columns by 2 rows, totaling 8 cells). I want to copy these values and place them in range D9:G10 on a second sheet.
I know how to handle single cell transfers in scripts, but I’m stuck when it comes to working with multiple cells at once. What’s the best approach to copy an entire range of values from one sheet and paste them into a different location on another sheet using Google Apps Script?
I’ve been doing this for months - batch processing with getValues() is definitely the way to go, but here’s something others missed. Always store your data in a variable first before setting it. Timing issues are real. Something like var data = sourceSheet.getRange('G10:J11').getValues(); targetSheet.getRange('D9:G10').setValues(data); works every time. This method keeps the actual values but strips formatting, which might be exactly what you want for pure data transfers. Learned this the hard way when my scripts kept failing because I was trying to read and write at the same time.
Use the Range class methods directly - it’s way more efficient. Grab references to both sheets with SpreadsheetApp.getActiveSpreadsheet().getSheetByName(). Then use getRange() to select G10:J11 and call copyTo() with your destination range. This beats getValues/setValues since it handles everything in one shot. Just make sure your destination matches the source size - you’re copying 4x2 cells, so D9:G10 works perfectly. I’ve found this method way more reliable for keeping cell formatting intact too.
try using getValues() & setValues(). fetch data using sheet1.getRange(‘G10:J11’).getValues() then set it on sheet2 with sheet2.getRange(‘D9:G10’).setValues(). it’s a neat way to handle bulk moves without fiddling with each cell.