0

I was wondering if I can copy a certain range of cells in Google Sheet File A and paste it to another Google Sheet File B.

More specifically, I'm referring not to sheets in the same Google Sheet(eg: sheet1, sheet2 in Google Sheet A) but 2 completely different Google Sheet Files(eg: Google Sheet File A, Google Sheet File B).

I have been googling it for a while but since Google Sheets and sheets share the same word I've been struggling to find a conclusive answer.

I think you can access different Google Sheets using sheet IDs in the macro but I'm not too sure if I'm on the right track.

0

Short answer: Yes, it's possible to copy a range from one spreadsheet to another

It's very likely that your googling didn't give you the results that you are looking for because you are not using the terms commonly used: spreadsheet and workbook, actually, the Google Apps Script use spreadsheet for the file and sheet for the sheets that it contains.

You could handle the spreadsheet files by using the Class Spreadsheet from the Spreadsheet Service and Clase File from the Drive Service. Also this could be done by using Advanced Services.

To get an spreadsheet object that represents an spreadsheet file, you could use the id, user or a file object.

Method          Return type     Brief description
------------------------------------------------------------------------------------------------
open(file)      Spreadsheet     Opens the spreadsheet that corresponds to the given File object.
openById(id)    Spreadsheet     Opens the spreadsheet with the given ID.
openByUrl(url)  Spreadsheet     Opens the spreadsheet with the given URL.

References

| improve this answer | |
  • Thanks so much! I had no clue I was using the wrong terms! – Joe Jan 14 at 1:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.