How GitHub Copilot and Azure OpenAI accelerate VBA and Office Script development — generating, refactoring, and documenting automation code intelligently.
A company has 15 years of undocumented VBA macros across 200+ Excel workbooks. The original developer has left. New automation requests take weeks because developers must reverse-engineer existing code before adding features. Documentation is nonexistent.
' BEFORE: Developer writes this manually
Sub GenerateMonthlyReport()
Dim ws As Worksheet
Dim lastRow As Long
Set ws = ThisWorkbook.Sheets("Data")
lastRow = ws.Cells(ws.Rows.Count, 1).End(xlUp).Row
' ... 80 more lines of boilerplate
End Sub
' AFTER: GitHub Copilot generates from comment
' Generate monthly sales report: group by region,
' calculate totals, apply formatting, email to managers
Sub GenerateMonthlyReport()
Dim wsData As Worksheet, wsReport As Worksheet
Dim dictRegion As Object
Set dictRegion = CreateObject("Scripting.Dictionary")
Set wsData = ThisWorkbook.Sheets("SalesData")
Set wsReport = ThisWorkbook.Sheets("Report")
Dim i As Long, lastRow As Long
lastRow = wsData.Cells(wsData.Rows.Count, 1).End(xlUp).Row
' Group sales by region
For i = 2 To lastRow
Dim region As String, amount As Double
region = wsData.Cells(i, 3).Value
amount = wsData.Cells(i, 5).Value
If dictRegion.Exists(region) Then
dictRegion(region) = dictRegion(region) + amount
Else
dictRegion.Add region, amount
End If
Next i
' Write to report sheet with formatting
wsReport.Cells.Clear
wsReport.Range("A1").Value = "Region"
wsReport.Range("B1").Value = "Total Sales"
wsReport.Range("A1:B1").Font.Bold = True
Dim row As Long: row = 2
Dim key As Variant
For Each key In dictRegion.Keys
wsReport.Cells(row, 1).Value = key
wsReport.Cells(row, 2).Value = dictRegion(key)
wsReport.Cells(row, 2).NumberFormat = "$#,##0.00"
row = row + 1
Next key
' Email report to managers
Call EmailReportToManagers(wsReport)
End Sub
' Copilot generated 95% of this from the 3-line comment above
Let's discuss how AI-enhanced VBA & Office Automation can deliver similar results for your organization.
Start the Conversation