0

I need to copy an array of data from one file to another, it needs to be pasted into the destination sheet from column F:J, while in the source file the data is in columns A:D

function copyRange() {
var source = SpreadsheetApp.openById("xxx");
var ssheet = source.getSheetByName("Source"); 
var srow = ssheet.getLastRow();
var srange = ssheet.getRange(8, 1, srow, 5).getValues();
var destination = SpreadsheetApp.openById("yyy");
var dsheet = destination.getSheetByName("Destination");
var drange = dsheet.getRange(5, 6, srow, 10);
drange.setValues(srange);}

I keep getting the error "Incorrect range width, was 5 but should be 10" I assume (I'm a total and utter newbie) that this refers to the number of columns in the destination range, but I don't get why that should be 10 when the data in the source range is in 5 columns?

1 Answer 1

2

Actually, I just figured it out myself - the columns aren't counted from A, but from the first specified one. Changing the 10 to 5 in the destination fixed it. Sorry for wasting time

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.