Excelgoodies logo +31 97 010285556

LEARN THIS HANDS ON

Power Apps & Power Automate

. Live Online FILLING FAST
View all upcoming batches
Power Automate vs Office Scripts vs VBA in 2026: Building the Right Excel Automation Stack

Power Automate vs Office Scripts vs VBA in 2026: Building the Right Excel Automation Stack

The month-end Excel pack is due, the shared workbook is locked again, and the one person who understands the VBA macros is on holiday. You know automation could fix this, but between Power Automate, Office Scripts, and legacy VBA, it's not obvious what to bet on. This guide walks through a realistic Excel-centric workflow and shows how to split work between these three tools in 2026 without painting yourself into a corner.

The Scenario: Monthly Sales Pack Chaos

Imagine a commercial team that publishes a monthly sales performance pack.

Current process:

  1. Sales data lands in a shared folder as multiple CSV exports from the CRM.
  2. An analyst opens a master Excel file, clicks a button to run VBA macros that:
    • Import CSVs
    • Refresh pivot tables
    • Apply formatting
  3. The analyst manually:
    • Saves PDFs for each region
    • Emails them to regional managers
    • Updates a SharePoint folder

Pain points:

  • The macros only run on one desktop machine.
  • When IT pushes an Office update, something breaks.
  • Regional managers want the pack earlier and more frequently.
  • Leadership wants auditability and fewer single points of failure.

The question: How do you redesign this using Power Automate, Office Scripts, and maybe still some VBA, in 2026?


The Three Players in 2026 (Short, Practical View)

Power Automate

Think of Power Automate as your workflow orchestrator:

  • Runs in the cloud.
  • Listens for events (file added to SharePoint, email received, schedule, HTTP calls).
  • Connects services (SharePoint, Outlook, Teams, Power BI, Dataverse, external APIs).
  • Can call Office Scripts to manipulate Excel files.

Best at:

  • Scheduling and triggers.
  • Cross-system integration.
  • Approvals and notifications.

Office Scripts

Office Scripts is your Excel-in-the-cloud automation engine for modern workbooks:

  • TypeScript-based scripts that run against Excel on the web.
  • Works on files in OneDrive/SharePoint.
  • Can be called from Power Automate.

Best at:

  • Data shaping and formatting in cloud-hosted workbooks.
  • Replacing many “classic macro” tasks for .xlsx files.
  • Reusable, testable logic that doesn’t depend on a specific desktop.

VBA

VBA is still your local Excel engine:

  • Runs only in desktop Excel.
  • Deep integration with legacy features (forms, COM add-ins, older file formats).
  • Mature, widely used in long-lived workbooks.

Best at:

  • Complex legacy models that cannot move to the web.
  • Interacting with local resources (fileshares, legacy ODBC drivers, legacy add-ins).
  • Quick one-off automation on your own machine.

In 2026, you rarely choose only one of these. You design a stack.


Mapping the Scenario to Each Tool

Let’s break the monthly sales pack into chunks and assign the right tool.

1. Data Ingestion and Trigger

Requirement: When new sales CSVs land in SharePoint, kick off the process.

Best fit: Power Automate

  • Trigger: When a file is created in a folder (SharePoint or OneDrive).
  • Conditions: Only start when all region files are present, or when a specific naming pattern is matched.

Flow outline:

  1. Trigger on new file in Shared Documents/Sales/Incoming.
  2. Check filename (e.g. Sales_YYYYMM_Region.csv).
  3. Use a control step to wait until all expected region files exist.
  4. Call an Office Script to process the data.

This removes the “analyst must remember to run the macro” step.

2. Data Transformation and Workbook Refresh

Requirement: Import CSVs, clean data, refresh calculations, update pivot tables.

Option A: Office Scripts (cloud-first)

If your main workbook lives in SharePoint as .xlsx and uses modern features:

  • Use an Office Script to:
    • Clear existing data ranges.
    • Load CSV content into tables.
    • Refresh formulas and pivot tables.
    • Apply basic formatting.

Example Office Script (simplified) to replace a common VBA pattern:

function main(workbook: ExcelScript.Workbook) {
  const ws = workbook.getWorksheet("Data");
  const table = workbook.getTable("SalesTable");

  // Clear existing rows (keep headers)
  const rowCount = table.getRowCount();
  if (rowCount > 0) {
    table.getRangeBetweenHeaderAndTotal().clear(ExcelScript.ClearApplyTo.contents);
  }

  // Assume Power Automate passes data as a JSON array
  const input = workbook.getCustomProperty("SalesJson").getValue() as string;
  const rows: (string | number)[][] = JSON.parse(input);

  // Add new rows
  table.addRows(-1, rows);

  // Refresh pivot tables on the "Report" sheet
  const reportSheet = workbook.getWorksheet("Report");
  reportSheet.getPivotTables().forEach(pt => pt.refresh());
}

Power Automate would:

  1. Read CSV files.
  2. Build a JSON array of rows.
  3. Store it in a custom property or named cell.
  4. Call the Office Script.

Option B: VBA (legacy or complex desktop models)

If your core model:

  • Is macro-enabled (.xlsm).
  • Uses legacy add-ins or features not supported in Excel on the web.

You might keep a VBA macro to do the heavy lifting and just let Power Automate orchestrate when it runs via a desktop flow.

A typical VBA import macro:

Sub ImportSalesFiles()
    Dim path As String, fileName As String
    Dim ws As Worksheet, qt As QueryTable

    path = "C:\Sales\Incoming\"
    Set ws = ThisWorkbook.Sheets("Data")

    ' Clear old data
    ws.UsedRange.ClearContents

    fileName = Dir(path & "Sales_*.csv")
    Do While fileName <> ""
        With ws.QueryTables.Add(Connection:="TEXT;" & path & fileName, _
                                 Destination:=ws.Cells(ws.Rows.Count, 1).End(xlUp).Offset(1, 0))
            .TextFileCommaDelimiter = True
            .Refresh BackgroundQuery:=False
        End With
        fileName = Dir
    Loop

    ' Refresh pivots
    Dim pt As PivotTable
    For Each pt In ws.Parent.PivotTables
        pt.RefreshTable
    Next pt
End Sub

Then use a Power Automate desktop flow to open the workbook and run ImportSalesFiles on a schedule.

Trade-off: More fragile (relies on a specific machine), but sometimes necessary.

3. Report Generation (Per Region Files / PDFs)

Requirement: Generate a PDF or Excel file per region and publish it.

Best fit: Power Automate + Office Scripts (if workbook is cloud-ready)

Pattern:

  1. Power Automate loops through a list of regions.
  2. For each region:
    • Calls an Office Script that sets a slicer/filter.
    • Saves a copy of the filtered report as PDF in a SharePoint folder.

Office Script snippet to set a slicer and export a sheet:

function main(workbook: ExcelScript.Workbook, region: string) {
  const reportSheet = workbook.getWorksheet("Report");

  // Set region slicer
  const slicer = workbook.getSlicer("RegionSlicer");
  slicer.clearFilters();
  slicer.getSlicerItems().forEach(item => {
    item.setSelected(item.getCaption() === region);
  });

  // Export as PDF to a temporary location
  // (Power Automate uses "Run script" output to get a file)
  const pdf = reportSheet.getPageLayout().exportAsFixedFormat(ExcelScript.FixedFormatType.pdf);
  return { pdfContent: pdf }; // PA saves this as a file
}

If export APIs are limited in your tenant, you might:

  • Let Office Script just set the filters.
  • Use Power Automate’s Export to PDF (Excel Online connector) if available.

If you are stuck on desktop-only features, you again fall back to VBA + desktop flows.

4. Distribution and Notifications

Requirement: Email or Teams message to each regional manager with their report.

Best fit: Power Automate

Once files are generated in SharePoint:

  • Use a For each loop over regions.
  • Look up the manager’s email from:
    • A SharePoint list
    • A Dataverse table
    • An Excel mapping table
  • Send emails with attachments or links.
  • Post a summary in a Teams channel.

No need for VBA or Office Scripts here.


When to Prefer Each Tool: A Practical Checklist

Choose Power Automate when…

  • You need:
    • Schedules, triggers, and approvals.
    • Integration across services (SharePoint, Outlook, Teams, Power BI, external APIs).
    • Governance, logging, and run history.
  • The process must keep running when:
    • Laptops are off.
    • People leave the team.

Typical use in our scenario:

  • Trigger on new data.
  • Orchestrate the monthly run.
  • Call Office Scripts or desktop flows.
  • Distribute outputs.

Choose Office Scripts when…

  • Your workbooks are:
    • Stored in OneDrive/SharePoint.
    • .xlsx (not .xlsm) and designed for web compatibility.
  • You need to:
    • Clean and reshape data in Excel.
    • Refresh pivots and formulas.
    • Apply formatting rules.
  • You want:
    • Reusable, testable scripts.
    • No dependency on a specific PC.

In our scenario, Office Scripts is ideal for:

  • Importing cleaned data into tables.
  • Refreshing the report sheet.
  • Preparing per-region views.

Keep or Use VBA when…

  • You have:
    • Complex legacy models that can’t be moved easily.
    • Heavy use of COM add-ins or legacy ODBC drivers.
    • Custom forms and interactions that don’t have web equivalents.
  • You need to:
    • Automate local file operations not available in the cloud.
    • Interface with older line-of-business systems.

In the sales pack scenario, VBA stays when:

  • The workbook uses features not supported in Excel on the web.
  • Rewriting would be a multi-month project.

Use Power Automate desktop flows as a bridge rather than rewriting everything at once.


Designing a Hybrid Stack That Won’t Hurt Later

Instead of “VBA vs Office Scripts vs Power Automate”, think layers:

  1. Orchestration layer (Power Automate)

    • Triggers, schedules, approvals.
    • Calls into Excel logic (Office Scripts or VBA via desktop flows).
  2. Excel logic layer (Office Scripts / VBA)

    • Business rules.
    • Data transformations.
    • Report shaping.
  3. Storage and access layer (SharePoint/OneDrive/Dataverse)

    • Where files and logs live.
    • Where configuration (e.g. region-to-manager mapping) is stored.

Design principles:

  • Keep business rules close to the workbook

    • Use Office Scripts or VBA for logic that depends on workbook structure.
    • Avoid burying cell references and formulas in Power Automate expressions.
  • Keep orchestration outside the workbook

    • Triggers, schedules, and notifications in Power Automate.
    • That way, swapping Office Scripts for VBA (or vice versa) doesn’t break the whole process.
  • Use configuration tables, not hard-coded values

    • Store region lists, email addresses, and thresholds in a SharePoint list or a config sheet.
    • Read them from Power Automate or scripts.

Applied to our scenario, a robust 2026 design looks like:

  • Power Automate:

    • Trigger on new month’s data.
    • Read config (regions, managers) from SharePoint.
    • Call an Office Script to refresh the master workbook.
    • Call an Office Script to generate per-region outputs.
    • Distribute via email/Teams.
  • Office Scripts:

    • Encapsulate all workbook-specific logic.
  • VBA:

    • Only where the workbook can’t be modernised yet, wrapped by desktop flows.

Practical Takeaway: Start by Splitting the Process, Not the Tools

Before you argue Power Automate vs Office Scripts vs VBA, list the steps in your workflow and mark each one as:

  • Trigger/Integration → Power Automate.
  • Excel logic on cloud-ready files → Office Scripts.
  • Excel logic on legacy/desktop-only models → VBA (optionally wrapped by desktop flows).

Do this for your next Excel automation project and you’ll usually end up with a hybrid stack that:

  • Reduces manual work and single points of failure.
  • Keeps legacy VBA where it still adds value.
  • Moves new logic into Office Scripts and Power Automate, where it’s easier to govern and share.

That mapping exercise is the fastest way to choose the right automation stack for your Excel-centric workflows in 2026.

Editor's Note

This article reflects how Excel-focused teams are gradually shifting from purely desktop VBA automation to hybrid stacks that combine Power Automate, Office Scripts, and legacy macros, especially in SharePoint- and OneDrive-based environments.

Professionals who want to apply these patterns to their own data can explore Excelgoodies' Power Automate Course programme - taught live by instructors, with certification awarded once a real project is running at work.

Insights compiled through ongoing industry research and discussions within the Excelgoodies Analytics Community.

Power Automate

New

Next Batches Now Live

Power BIPower BI
SQLSQL
Power AppsPower Apps
Power AutomatePower Automate
Microsoft FabricMicrosoft Fabrics
AzureAzure Data Engineering
Explore Dates & Reserve Your Spot → Reserve Your Spot →