How to Combine Multiple Google Sheets Imports Into One Master Sheet
The Google Sheets import extension currently has a bug that prevents you from adding more than two scheduled imports to a single Google Sheet. Until that is fixed, the workaround is to keep one Google Sheet per website import and pull all of them into a single Master sheet using a short Apps Script. This article walks through that setup end to end.
This is a temporary workaround. Once the Google Sheets import extension is updated to support more than two schedules per sheet, you will be able to add all imports directly to one sheet without using a script.
What You Need
Before starting, make sure you have the following in place.
| Requirement | Details |
|---|---|
| Source Sheets | One Google Sheet per website, each already configured with its own ProfitMetrics import schedule |
| Master Sheet | A new, empty Google Sheet that will hold the combined data from every source |
| Access | Edit access to the Master sheet and at least view access to every source sheet, all under the same Google account |
Step 1 — Get the IDs of your source spreadsheets
Open the first source sheet in your browser and look at the URL:
https://docs.google.com/spreadsheets/d/2bN6MVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms/edit
The ID is the long string between /d/ and /edit:
2bN6MVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgVE2upms
Copy the ID and save it somewhere. Repeat for every source sheet you want to combine. While you are there, also note the exact tab name (e.g. Sheet1) of the all the tabs inside each source that hold the data you want to import — you will need this in Step 3.
Step 2 — Open the Apps Script editor in your Master sheet
Open the Master sheet and, in the top menu, click Extensions → Apps Script.
A new tab opens with the Apps Script code editor. Delete any default content already in the editor so you start with an empty file.
Step 3 — Paste the script
Paste the code below into the editor. Replace each YOUR_SOURCE_SHEET_ID placeholder with an ID you copied in Step 1, and update sourceTab and masterTab to match your tab names.
const SOURCES = [
{ id: "YOUR_SOURCE_SHEET_1_ID", sourceTab: "YOUR_SOURCE_TAB_NAME", masterTab: "TAB_NAME_TO_USE_IN_IMPORT SHEET" },
{ id: "YOUR_SOURCE_SHEET_2_ID", sourceTab: "YOUR_SOURCE_TAB_NAME", masterTab: "TAB_NAME_TO_USE_IN_IMPORT SHEET" },
];
function pullAllData() {
const master = SpreadsheetApp.getActiveSpreadsheet();
SOURCES.forEach(({ id, sourceTab, masterTab }) => {
try {
const sourceSheet = SpreadsheetApp.openById(id).getSheetByName(sourceTab);
if (!sourceSheet) {
console.log(`Tab "${sourceTab}" not found in spreadsheet ${id}`);
return;
}
const data = sourceSheet.getDataRange().getValues();
if (data.length === 0) {
console.log(`No data in "${sourceTab}" from spreadsheet ${id}`);
return;
}
let masterSheet = master.getSheetByName(masterTab);
if (!masterSheet) {
masterSheet = master.insertSheet(masterTab);
}
masterSheet.clearContents();
masterSheet.getRange(1, 1, data.length, data[0].length).setValues(data);
console.log(`Pulled ${data.length} rows into "${masterTab}"`);
} catch (e) {
console.error(`Failed to pull from ${id}: ${e.message}`);
}
});
}
Each entry in SOURCES represents one source sheet:
| Field | Description |
|---|---|
| id | The long spreadsheet ID from the source sheet's URL — the string between /d/ and /edit that you copied in Step 1 |
| sourceTab | The exact name of the tab on the source sheet you are importing data from (e.g. ProfitMetrics, as shown at the bottom of the source sheet) |
| masterTab | The name you want the new tab to have in the Master sheet (e.g. IMPORT_DK). The script will create this tab if it does not already exist. |
Add as many entries as you have source sheets. Save the script with the floppy disk icon or Ctrl+S.
Step 4 — Run it once manually to grant permissions
At the top of the editor, make sure pullAllData is selected in the function dropdown, then click Run.
Google will prompt you to authorise the script:
- Click Review permissions.
- Choose the Google account that owns the Master sheet.
- Click Allow to grant access to your spreadsheets.
After authorising, the script runs. Open the execution log at the bottom of the editor and check that you see Pulled X rows into "..." for each source. Errors are printed there too if any source fails.
Step 5 — Set up the automatic trigger
In the Apps Script editor, click the clock icon in the left sidebar to open Triggers.
In the bottom right corner, click + Add Trigger and fill in the form:
| Field | Value |
|---|---|
| Choose which function to run | pullAllData |
| Choose which deployment should run | Head |
| Select event source | Time-driven |
| Select type of time-based trigger | Whatever schedule you need (hourly, daily, etc.) |
Click Save.
Google will show the same authorisation prompt as in Step 4 — this time for the trigger itself. Click Review permissions, and click Allow again. The trigger will not run on its schedule until you complete this second authorisation.
Both authorisations are required. The first one in Step 4 lets the script run, and the second one here lets Google run the script automatically on the trigger schedule.
Once both permissions are granted, the Master sheet will pull data from every source on the schedule you chose, with no add-ons and no further changes needed.
Troubleshooting
If the Master sheet is not updating as expected, check these first.
| Symptom | What to check |
|---|---|
| Trigger never fires | Open Triggers in the sidebar and confirm the trigger is listed and enabled. If it shows an authorisation error, click into it and re-grant permissions. |
| Tab "..." not found in logs | The sourceTab value in the script does not match the actual tab name in that source sheet. Tab names are case-sensitive and must match exactly. |
| Failed to pull from ... in logs | The spreadsheet ID is wrong, or the Google account running the script does not have access to that source sheet. Open the source URL while signed in to confirm. |
| Master tab is empty | The source sheet has no data in the referenced tab. Open the source and confirm the ProfitMetrics import has populated rows there. |
| Old data still showing | The source import has not run since the last trigger. The Master pulls whatever is currently in the source — it does not trigger the source imports themselves. |
If the issue persists, contact support@profitmetrics.io