Search code examples
google-apps-scriptgoogle-sheetsgoogle-sheets-formulagoogle-sheets-apispreadsheet

how we can find the connexion of importrange function sources in ActiveSpreadsheets?


there are some sheets in my spreadsheet and I want find how many times I use importrange function to know every connection in my active spreadsheet. Is there a formula to find this values?


Solution

  • Count importrange in all of the sheets in a spreadsheet.

    function countImportRange() {
      const ss = SpreadsheetApp.getActive();
      const n = ss.getSheets().reduce((a,sh,i) => {
        a += sh.getValues().flat().filter(e => e.toString().toLowerCase().includes('importrange')).filter(e => e).length;
        return a;
      },0);
      Logger.log(n);
    }