Search code examples
google-sheetsgoogle-forms

In new Google Sheets, how can I import data from other spreadsheet?


I have the same problem with this topic How do I link a cell in Google Spreadsheets to a cell in another document? and they suggest to use IMPORTRANGE() with key inside but I didn't see any key in my sheet URL.

I have one Google survey form for gathering many data from our staff and raw data will generate to Google Sheets as report(Responses).

I need to import raw data from report(Responses) to other Google Sheets and summarize a report in it.

How can I get data from this sheet?


Solution

  • IMPORTRANGE() is currently not supported in the new google sheets. It will be supported in future but at the moment no one knows when exactly.

    You can switch back to the old google sheets where IMPORTRANGE() is still working as usual. Or you can use a script e.g.:

    function myImportRange( key , sheetrange) {
     var shra = sheetrange.split("!") ;
     if (shra.length==1) shra[1]=shra[0], shra[0]="";  
    
     var sheetstring = shra[0].replace( /'/g , "")
     var rangestring = shra[1] 
    
     var source = SpreadsheetApp.openById( key )    
     if ( sheetstring.length==0 ) sheet = source.getSheets()[0] ;
     else sheet = source.getSheetByName(sheetstring) ;
    
     return  sheet.getRange( rangestring ).getValues(); 
    } 
    

    You can find the original post of this script written by Ahab here: https://productforums.google.com/forum/?hl=en#!category-topic/docs/how-do-i/f_r7iVtUThM

    Edit: IMPORTRANGE () is now supported.