Excelgoodies logo +31 97 010285556

LEARN THIS HANDS ON

Power Apps & Power Automate

. Live Online FILLING FAST
View all upcoming batches
Replacing Excel VBA Macros with Power Automate: When It Makes Sense and When It Doesn’t

Replacing Excel VBA Macros with Power Automate: When It Makes Sense and When It Doesn’t

You’ve got a folder of Excel workbooks, each with a slightly different VBA macro that emails reports, moves files, or updates a tracker. Someone has now asked you to “modernise” all of it and replace the macros with Power Automate. The risk is obvious: you can spend weeks migrating logic only to end up with slower, more fragile flows.

This article walks through a realistic scenario and shows where replacing Excel VBA macros with Power Automate is a clear win, where it’s a bad fit, and how to design a hybrid approach that doesn’t break what already works.

The scenario: 120 macro-enabled workbooks nobody wants to touch

Picture a shared network folder (or SharePoint library) with around 120 Excel workbooks:

  • Each workbook is macro-enabled (.xlsm).
  • Each has one or more ThisWorkbook or module-level procedures that run on Workbook_Open, Workbook_BeforeClose, or via a button.
  • Typical tasks:
    • Refreshing external data connections.
    • Copying data into a consolidated “master” workbook.
    • Generating and emailing PDF reports to distribution lists.
    • Archiving last month’s data to another folder.

The pain points:

  • Maintenance risk: Macros break when users rename sheets, move files, or change connection strings.
  • Security friction: Users see macro warnings; IT is tightening policies on unsigned VBA.
  • Platform mismatch: Some users are now on Excel for the web or using tablets; the macros don’t run there.
  • Auditability: It’s hard to say who ran what, when, and with which parameters.

Management wants “everything moved to Power Automate”. The right answer is rarely “everything”. Let’s work through the decision.

Core differences: VBA vs Power Automate for Excel work

Before deciding what to move, it helps to be precise about how the two tools behave.

What VBA is good at

VBA in Excel is:

  • In-process and synchronous: Code runs inside the Excel application, with direct access to the workbook object model.
  • Stateful and interactive:
    • Can respond to user events (selection changes, button clicks, double-clicks).
    • Can manipulate the active workbook, selection, formatting, and formulas in real time.
  • Rich for UI and calculation logic:
    • Can build custom forms, complex calculation sequences, and sheet-driven workflows.
  • File-system friendly (on desktop):
    • Can read/write local and network files using FileSystemObject or native VBA I/O.

Limitations that matter for our scenario:

  • Desktop-bound: Macros require Excel on a supported OS and won’t run in Excel for the web.
  • Execution is tied to user sessions: No native scheduling; you rely on users opening files or Windows Task Scheduler launching Excel.
  • Security and governance: Macro policies, unsigned code, and limited central logging.

What Power Automate is good at

Power Automate (cloud flows) is:

  • Server-side and event-driven:
    • Triggers on file changes, schedules, HTTP calls, approvals, etc.
    • Runs without a user having Excel open.
  • Strong at orchestration and integration:
    • Connectors for SharePoint, Outlook, Teams, OneDrive, Dataverse, and many third-party systems.
  • Auditable:
    • Run history, error details, and per-step logs.
  • Cross-platform:
    • Works regardless of whether users are on desktop, web, or mobile.

Limitations relevant to Excel migration:

  • Excel connectors are table-centric:
    • The standard Excel Online (Business) connector works with tables in workbooks stored in OneDrive for Business or SharePoint.
    • It doesn’t expose the full object model like VBA (no arbitrary range formatting, chart manipulation, or event handling).
  • Desktop automation is separate:
    • Power Automate Desktop can automate Excel via UI and COM, but that’s still tied to a machine and logged-on context.
  • Performance and throttling:
    • Large loops over rows via connectors can be slower than in-memory VBA operations.

With that in mind, we can classify tasks in the 120-workbook scenario.

Good candidates to move from VBA to Power Automate

In practice, flows are a strong replacement for macros that:

  1. Are primarily about orchestration, not UI
  2. Depend on events, schedules, or integrations
  3. Operate on structured data (tables) in SharePoint/OneDrive

1. Scheduled refresh and distribution

Common macro pattern:

  • Open a workbook at 07:00.
  • Refresh connections.
  • Save a PDF.
  • Email it to a list.

This is usually better in Power Automate if you can:

  • Store the workbook in SharePoint or OneDrive.
  • Move the data source to something the flow can access directly (e.g. SharePoint list, SQL, Power BI dataset).

A typical cloud flow design:

  • Trigger: Recurrence (e.g. every weekday at 07:00).
  • Actions:
    • Get data from source (e.g. SQL, SharePoint, or a Power BI export step if appropriate).
    • Populate an Excel template table (if you still need Excel for layout).
    • Use a convert-to-PDF capability where available (for example, via a dedicated connector such as OneDrive for Business – Convert file or SharePoint – Convert file, or a Power Automate Desktop sub-flow if you need the Excel rendering engine).
    • Send email with PDF attached via Outlook connector.

Benefits over VBA:

  • No dependency on a user logging in.
  • Central error logging and retry.
  • Easier to rotate recipients or add approvals.

2. File routing and archiving

Macro pattern:

  • On close, move the workbook or a generated file to an archive folder.
  • Rename with a timestamp.

Power Automate is a natural fit if:

  • The files live in SharePoint or OneDrive.
  • The rules are based on metadata (e.g. file name, library column, or path).

Flow design:

  • Trigger: When a file is created or modified in a folder (SharePoint/OneDrive).
  • Actions:
    • Check conditions (e.g. file name pattern or metadata value).
    • Move file to archive location.
    • Rename using a timestamp.

Compared to VBA:

  • No macro security prompts.
  • Works for files created by any user.
  • Consistent behaviour across devices.

3. Simple row-level data operations on tables

If your macros:

  • Append rows from multiple workbooks into a master table.
  • Apply simple transformations (e.g. set a status column, copy values, filter rows).

Then Power Automate can often replace this using:

  • Excel Online (Business) connector for table operations.
  • SharePoint as the consolidation target instead of a “master workbook”.

Typical pattern:

  • Trigger: When a file is created in a library.
  • Actions:
    • List rows in table from the new workbook.
    • Loop through rows and create items in a SharePoint list.

This shifts your “master” from Excel to SharePoint or Dataverse, which is generally easier to query and integrate.

Poor candidates: when VBA is still the right tool

There are cases where replacing Excel VBA macros with Power Automate will create more problems than it solves.

1. Heavy interactive logic inside Excel

Macros that:

  • React to Worksheet_Change to validate user input.
  • Control complex forms or guided workflows.
  • Update charts, conditional formats, or named ranges based on user actions.

Power Automate cloud flows cannot:

  • Hook into Excel’s in-workbook events in real time.
  • Manipulate the active workbook UI for a user session.

You could use Power Automate Desktop to script Excel, but that:

  • Still runs on a specific machine.
  • Depends on the UI state and is fragile if users interact mid-run.

For these, VBA (or Office Scripts if you’re able to move to web and TypeScript) remains a better fit.

2. High-volume, in-memory calculations tightly coupled to sheets

Macros that:

  • Iterate over tens of thousands of cells applying complex logic.
  • Use arrays and in-memory operations to avoid calculation overhead.

Power Automate’s table-based operations:

  • Are network-bound and subject to API limits.
  • Will generally be slower than in-process VBA for high-volume cell operations.

Unless you can move the logic to a database, Power BI, or a more scalable compute layer, keeping this in VBA is often more practical.

3. Local-only file operations without cloud storage

If your environment:

  • Keeps sensitive files strictly on local drives or on-prem file shares without gateway integration.

Then cloud flows:

  • Cannot directly access those files without additional setup (e.g. on-premises data gateway or Power Automate Desktop).

If you’re not in a position to introduce those components, VBA remains the straightforward solution for local file automation.

Designing a migration strategy for the 120 workbooks

Back to the scenario: 120 macro-enabled workbooks, mostly doing a mix of refresh, distribution, consolidation, and archiving.

A practical approach:

  1. Inventory and classify macros

    • For each workbook, capture:
      • Triggers (open, close, button click, scheduled via Windows).
      • Data sources (SharePoint, SQL, CSV, local files).
      • Targets (emails, other workbooks, folders).
    • Tag each macro as:
      • Orchestration (refresh, move, send).
      • Interactive (user-driven UI logic).
      • Calculation-heavy (bulk cell operations).
  2. Move orchestration macros first

    • Identify:
      • Scheduled refresh + email jobs.
      • File routing and archiving tasks.
      • Simple consolidation into a master file.
    • For each, design a cloud flow:
      • Move source/target files to SharePoint/OneDrive where possible.
      • Use connectors for data sources instead of Excel connections when feasible.
  3. Stabilise data storage

    • Replace “master workbook” patterns with:
      • SharePoint lists for tabular data that needs collaborative access.
      • Dataverse or SQL for more complex schemas or higher volume.
    • Keep Excel as a front-end for reporting where needed, but not as the main data store.
  4. Leave or refactor interactive macros

    • For interactive logic that must stay in Excel:
      • Keep it in VBA for now.
      • Standardise and simplify code where possible.
      • Document dependencies (sheet names, ranges, named ranges).
    • If your users are mainly on Excel for the web and you have the right licensing, consider Office Scripts as a future alternative, but treat that as a separate project.
  5. Introduce a hybrid pattern

    • Use Power Automate for:
      • Scheduling, orchestration, notifications, approvals.
    • Use VBA for:
      • In-workbook, user-driven operations and complex calculation sequences.

The result isn’t “no VBA anywhere”, but fewer macros doing back-end work that Power Automate can handle more reliably.

Example: replacing a mail-out macro with a flow

Take a common macro in the scenario: emailing a report when a user clicks a button.

The original VBA macro

This macro:

  • Saves the active workbook as PDF.
  • Sends it to a fixed distribution list.
Sub SendMonthlyReport()
    Dim pdfPath As String
    Dim reportName As String
    Dim ws As Worksheet

    reportName = "MonthlyReport_" & Format(Date, "yyyymmdd") & ".pdf"
    pdfPath = ThisWorkbook.Path & "\" & reportName

    Set ws = ThisWorkbook.Sheets("Report")
    ws.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=pdfPath, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False

    Dim olApp As Object
    Dim olMail As Object

    Set olApp = CreateObject("Outlook.Application")
    Set olMail = olApp.CreateItem(0)

    With olMail
        .To = "finance-team@example.com; ops@example.com"
        .Subject = "Monthly Report - " & Format(Date, "dd MMM yyyy")
        .Body = "Please find the monthly report attached."
        .Attachments.Add pdfPath
        .Send
    End With

    Set olMail = Nothing
    Set olApp = Nothing
End Sub

Issues:

  • Runs only on a user’s desktop with Outlook configured.
  • Distribution list is hard-coded.
  • No central log of who sent what, when.

A Power Automate replacement pattern

Assumptions for the replacement:

  • The report workbook is stored in SharePoint.
  • The “Report” worksheet is laid out consistently.
  • You have a way to generate a PDF from the workbook in an automated fashion (for example, via a dedicated connector such as OneDrive for Business – Convert file or SharePoint – Convert file, or a Power Automate Desktop sub-flow that runs on a service machine).

Cloud flow design:

  • Trigger: When a user drops a file into a “Reports to send” library, or clicks a button in a Power Apps front-end that calls the flow.
  • Actions (high-level):
    • Get the file from SharePoint.
    • Generate the PDF using your chosen method.
    • Send email via Outlook connector to a distribution list stored in a SharePoint list or configuration file.
    • Log the send event in a SharePoint list (file name, timestamp, sender).

Benefits:

  • Works even if users are on web or mobile.
  • Distribution lists are maintained centrally.
  • You can add approvals, retries, and conditional routing without editing workbook code.

Governance and performance considerations

When you move logic from VBA to Power Automate, you also shift how it is governed and how it performs.

Governance

  • Ownership:
    • Cloud flows have explicit owners; you can add co-owners and manage them via environment roles.
  • Security:
    • Connections run under specific identities; access is controlled via Azure AD and connector permissions.
  • Audit:
    • Run history lets you see when flows ran, what they did, and where they failed.

Compared to VBA:

  • You get clearer accountability but must manage environment boundaries, solution lifecycle, and connection references.

Performance and limits

Key points to keep in mind:

  • Connector limits:
    • Excel and SharePoint connectors have throughput and pagination constraints. Large loops over rows can be slow.
  • Concurrency:
    • Multiple flows acting on the same file may cause conflicts. You may need to design for single-writer patterns or use locking strategies (e.g. controlling triggers, using status flags).
  • Error handling:
    • Use scoped actions, try/catch-style patterns (parallel branches with “Run after”), and notifications for failures.

Where VBA may still be faster:

  • In-memory operations on large ranges with minimal external calls.

Where Power Automate wins:

  • Multi-system orchestration, scheduled tasks, and anything that benefits from central logging and retries.

A practical takeaway: start with orchestration, not everything

If you’re looking at a pile of macro-enabled workbooks and a directive to “move to Power Automate”, resist the temptation to translate every procedure line-by-line. Instead:

  • Identify the macros that coordinate systems (refresh, move, send) and move those first.
  • Keep macros that drive in-workbook interaction or heavy calculation where they are until you have a better platform for that logic.

You’ll end up with fewer, more robust flows, a smaller VBA footprint, and a migration that actually improves reliability instead of just changing where the complexity lives.

Editor's Note

This article reflects the gradual shift from workbook-bound VBA orchestration to centrally managed Power Automate flows, particularly in teams standardising on SharePoint and cloud-based collaboration while still relying on Excel for interactive work.

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 →