Skip to content

Every 15 minutes

Combine Excel files from OneDrive into one workbook

Every 15 minutes, rows from new Excel files dropped in a OneDrive folder are added to a table in one master Excel workbook, with the source file name on each row.

Runs
Every 15 minutes
Apps
Microsoft Excel, OneDrive
AI
Not needed
Access
Files.ReadWrite

Send this to your assistant

Create a ClickRuntime automation: every 15 minutes, take any new .xlsx file in my OneDrive folder "Store reports", read the rows from its first sheet and add them to the Sales table in Master.xlsx with the file name in the last column, then move the file to "Store reports/Imported".

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

When several stores, teams or clients each send an Excel file, someone spends time every week opening each one and pasting its rows into a master spreadsheet. People searching for how to import data from OneDrive into Excel usually mean exactly this: getting many files into one table.

This automation watches a OneDrive folder. Every 15 minutes it opens any new .xlsx file through Microsoft Graph, reads the rows on its first sheet and adds them to a table in your master workbook, with the source file name on each row. The file is then moved to an Imported subfolder.

Retail and franchise operators combining store reports, finance teams collecting department budgets and agencies merging client exports use it so the master workbook is always up to date and pivot tables refresh on real data.

What you get out of it

  • No copy and paste

    Rows go straight from each file into the master table.

  • Source on every row

    The file name column shows where each row came from, so mistakes can be traced back.

  • Each file once

    Imported files move to a subfolder, which also shows at a glance what has been processed.

  • Excel files, not just CSV

    It reads real .xlsx workbooks through Graph, so senders do not need to export anything.

  • Tables keep formulas working

    Rows land in an Excel table, so formulas, pivots and charts based on it pick up new data.

How it works

What happens, step by step

  1. Every 15 minutes the automation looks for new .xlsx files in the OneDrive folder.

  2. It opens each workbook's first sheet through Microsoft Graph and reads the used rows, skipping the header.

  3. It adds the rows to a table in your master workbook, with the source file name in an extra column.

  4. The imported file is moved to an Imported subfolder so it is not read twice.

Before it runs live

  • Connect Microsoft Excel
  • Connect OneDrive

What you get

RunsEvery 15 minutes
Combine Excel files from OneDrive into one workbooktoday, 9:00Succeeded
Excel · Master.xlsx · Sales tableAdded 214 rows from 3 files: store-berlin-oct.xlsx (71) · store-madrid-oct.xlsx (88) · store-lyon-oct.xlsx (55) Files moved to Store reports/Imported

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Microsoft Excel and OneDrive steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
combine_excel_files_from_onedrive_into_one_workbook.pyexample
from clickruntime import on_trigger, credentials, http

GRAPH = "https://graph.microsoft.com/v1.0"
FOLDER = "/me/drive/root:/Store reports"
ARCHIVE_PATH = "/drive/root:/Store reports/Imported"
MASTER = "/me/drive/root:/Master.xlsx:/workbook/tables/Sales"
COLS = 6   # columns in the Sales table, including the final "source file" column

@on_trigger
def run(event):
    h = {"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}
    files = [f for f in http.get(f"{GRAPH}{FOLDER}:/children", headers=h, params={"$top": 200}).json()["value"]
             if f.get("file") and f["name"].lower().endswith(".xlsx") and not f["name"].startswith("~$")]
    added = {}
    for f in files:
        base = f"{GRAPH}/me/drive/items/{f['id']}/workbook"
        sheet = http.get(f"{base}/worksheets", headers=h).json()["value"][0]["name"]
        used = http.get(f"{base}/worksheets('{sheet}')/usedRange(valuesOnly=true)", headers=h).json()["values"]
        rows = [(r + [""] * COLS)[:COLS - 1] + [f["name"]] for r in used[1:] if any(str(v).strip() for v in r)]
        for i in range(0, len(rows), 500):
            http.post(f"{GRAPH}{MASTER}/rows/add", headers=h, json={"values": rows[i:i + 500]}).raise_for_status()
        http.patch(f"{GRAPH}/me/drive/items/{f['id']}", headers=h,
                   json={"parentReference": {"path": ARCHIVE_PATH}}).raise_for_status()
        added[f["name"]] = len(rows)
    return {"files": len(added), "rows": sum(added.values()), "by_file": added}

FAQ

Common questions

Do all the files need the same columns?
Yes, in the same order as the master table. Rows are added as they are, so a file with an extra or missing column will shift the data. Ask your assistant to match columns by header name if your files vary.
Why does the master workbook need a table?
Graph adds rows to an Excel table, which grows as rows are added and keeps formulas and formatting consistent. Select your header row in Excel and use Insert > Table once before starting.
Does it work with files on SharePoint?
Yes. Point the folder and master paths at the SharePoint site's drive instead of /me/drive; the Microsoft app needs Sites.ReadWrite.All or access to that site.
What permissions does it need?
Files.ReadWrite. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Combine Excel files from OneDrive into one workbook” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.