FKFaiyaz M Khairaz
Home›Copilot Case Studies›VBA Macros with Copilot
VBA Macros with Copilot · Bridgestone Finance team

Copilot Wrote the VBA. Bridgestone Finance Ran It.

After a Copilot workshop with the Bridgestone finance team, one participant turned a recurring chore into one click: a VBA macro that sends each supplier a single, consolidated GST invoice-mismatch email. Microsoft 365 Copilot Chat wrote the code. They defined it, tested it and ran it.

ClientBridgestone, Finance team
ToolMicrosoft 365 Copilot Chat, no paid Copilot licence
BuiltExcel VBA macro + classic Outlook
ResultOne email per supplier: every invoice, a grand total, the right CC
69-second walkthrough with music. It also works with the sound off. Numbers, suppliers and email addresses are sample data.Get the sample file and macro ↓

The problem

Invoices that don't match GSTR-2B have to be chased with the supplier so they can correct their GST return. The data was already in Excel. Writing the emails was the slow part.

BeforeSupplier by supplier

  • Filter the mismatch sheet for one supplier
  • Copy their invoice lines into an email and format the table
  • Add up the tax and type the grand total
  • Look up who goes in To and CC, write the subject
  • Repeat for every supplier, and hope nothing was missed

AfterOne click

  • One email per supplier, however many invoice lines they have
  • All invoices in a table: invoice no, date, taxable value, IGST, CGST, SGST, total tax
  • Grand total calculated by the macro
  • To, CC and subject taken straight from the sheet
  • Mail Log sheet records every email that went out

Five steps: Define, Generate, Test, Modify, Execute

This is the lifecycle I teach for building anything with Copilot. Copilot does the writing. You own every step that needs judgement.

You

1 · Define the problem

Start with the sheet, not with Copilot. The table GST on Final for Mismatch Inv has one row per mismatched invoice, with the supplier code, invoice details, tax amounts, mail subject and To / CC addresses.

Then say what "done" looks like: one email per supplier, all their invoices, a grand total, recipients from the sheet, and a log.

Excel table of GST invoice mismatches: 46 invoices across 12 suppliers
You

1 · Describe it to Copilot Chat

Plain English is enough. Name the sheet, the table, the columns and the result.

PromptExcel table "GST" on sheet "Final for Mismatch Inv" has one row per invoice that doesn't match GSTR-2B: supplier code, supplier name, invoice no, date, taxable value, IGST, CGST, SGST, total tax, mail subject, To and CC emails. Write a VBA macro that sends ONE Outlook email per supplier with all its invoices in a table, a grand total, To and CC from the sheet, and logs each email in "Mail Log".

Tip: describe the columns. You don't need to paste invoice data into the chat.

Typing the prompt into Microsoft 365 Copilot Chat
Copilot

2 · Generate the code

Copilot Chat returns a complete macro: it groups the rows by supplier code, builds an HTML table per supplier, adds the grand total and creates the Outlook email. Copy it.

Copilot Chat generating the VBA macro
You

3 · Test the code

In Excel, press Alt + F11, choose Insert › Module, paste, and press F5. Always test on a copy of the file.

First run: Run-time error '9': Subscript out of range. Copilot had guessed a column called "Supplier Name". The real header is "Name of the Supplier". Errors like this are normal, and they are why testing is your job.

VBA editor showing Run-time error 9
Copilot

4 · Modify it with Copilot

Click Debug, note the highlighted line, and paste the error back into the same chat.

Follow-up promptI got Run-time error '9': Subscript out of range on ListColumns("Supplier Name"). In my sheet that column is called "Name of the Supplier". Please fix it.

Ask for a safety switch too: a test mode that opens each email with .Display instead of sending it with .Send.

Copilot Chat fixing the column name and adding a test mode
You

5 · Execute it again

Run it in test mode, open a few emails and check the totals against the sheet. When they are right, switch test mode off and run it for real.

Sample run: 46 invoice lines, 12 suppliers, 12 emails, each with its own invoice table, grand total and CC list, and 12 rows in the Mail Log.

Outlook email to one supplier with all invoices and a grand total

Code writing can now be outsourced.
Executing is in our hands.

Knowing the process

Copilot didn't know who to email or why. The finance team did.

Testing on a copy

Never run new code on the live file first.

Reading the error

Spotting the column name was the whole fix.

Deciding to send

Display first, check the numbers, then send.

The Copilot coding lifecycle

Steps 3 and 4 repeat until the test passes. Most macros need one or two rounds.

Lifecycle: Define, Generate, Test, Modify with Copilot when there is an error, then Execute

Try it yourself

A sample workbook with the same structure (made-up suppliers and amounts, example.com addresses) and a tidied-up version of the macro.

  1. Open the workbook and save it as .xlsm (macro-enabled).
  2. Alt + F11 › File › Import File › choose SendSupplierGSTEmails.bas.
  3. Leave TEST_MODE = True and press F5. Each email opens in Outlook. Nothing is sent.
  4. Check the emails, then set TEST_MODE = False to send.

Note: this needs classic Outlook for Windows. The new Outlook doesn't support VBA automation.

Faiyaz M Khairaz

Want your team building like this?

I'm Faiyaz M Khairaz, a Freelance AI Trainer and Microsoft Certified Trainer. My Copilot and Advanced Excel workshops are built on your team's own processes, so people leave with automations like this one, not just slides.

Talk to usConnect on WhatsApp