0

I want to use the IMPORTRANGE function every time I open one spreadsheet so this opened spreadsheet can be synchronized with another spreadsheet. So, in A1, I put a call formula like this:

=importrange("0AmEr9uNtZwnNdDFKMTVlbmZYZ3ZyOWM0aXpZS2twM1x";  "myData!A1:W384")

But this IMPORTRANGE call remains static. That is, once imported, the data isn't updated when the imported sheet is changed.

So what is wrong? I wonder if I can use IMPORTRANGE, a spreadsheet function, within a Google Apps Script (which is like JS code).

How can I call a spreadsheet function inside a script?

Rubén
  • 34,714
  • 9
  • 70
  • 166
craftApprentice
  • 2,697
  • 17
  • 58
  • 86
  • I think there is a answer to a similar question here: http://stackoverflow.com/questions/11143684/is-it-possible-to-do-importrange-in-google-apps-script . So, there's no way to use specifically the `importrange()`. I have to use `range.getValues()` and `range.setValues()`. – craftApprentice Dec 09 '13 at 01:11

1 Answers1

1

ImportRange does update automatically—just not instantly. Give it 5 minutes.

  1. It won't update until you open the spreadsheet and
  2. The one opening it must have "read" permission to the source.

If you really want to do it with code, use SpreadsheetApp.openById, getSheetByName, and getRange get/setValues.

Michael
  • 8,362
  • 6
  • 61
  • 88
Zig Mandel
  • 19,571
  • 5
  • 26
  • 36
  • One problem I see with `importrange()` is that it doesn't import comments. Are there a way to solve this? – craftApprentice Dec 09 '13 at 12:55
  • no, cant be done from importRange which imports only data. Even with gas you cant get comments, only cell notes which are different (https://developers.google.com/apps-script/reference/spreadsheet/range#getNotes()) – Zig Mandel Dec 09 '13 at 13:48