XXLFormula AI
Pro ProjectReportingAdvancedIncludes .xlsm

Dashboard Automation

5.0· 3,990 learners

A one-macro daily-report pipeline: freeze the UI, refresh all data connections and PivotTables, rebuild the charts, and export a PNG snapshot for stakeholders — all with structured error handling and calculation state restore.

Learners
3,990
Duration
4 hours
Difficulty
Advanced
Dashboard Automation.xlsm — VBA EditorFileEditViewInsertFormatDebugRunToolsAdd-InsWindowHelpRun Sub/UserForm (F5)Project — VBAProjectVBAProject (Budget Automation.xlsm)Microsoft Excel ObjectsSheet1 (Transactions)Sheet2 (Dashboard)Sheet3 (Settings)ThisWorkbookFormsfrmCategoryEditorModulesmodBudgetmodChartsmodUtilsClass ModulesclsTransactionProperties — modBudget(Name)modBudget(General) ▾    RefreshBudget ▾1Option Explicit23' Budget refresh — one-click month-end.4Public Sub RefreshBudget()5    Dim wsData As WorksheetwsDash As Worksheet6    Dim lastRow As Longi As Long78    On Error GoTo Fail9    Application.ScreenUpdating = False1011    Set wsData = ThisWorkbook.Worksheets("Transactions")12    Set wsDash = ThisWorkbook.Worksheets("Dashboard")13    lastRow = wsData.Cells(wsData.Rows.Count"A").End(xlUp).Row1415    For i = 2 To lastRow16        Call AddToCategory(wsDash_17            CStr(wsData.Cells(i"C").Value), _18            CCur(wsData.Cells(i"D").Value))19    Next i2021    Application.ScreenUpdating = True22    MsgBox "Budget refreshed."vbInformation23    Exit Sub24Fail:25    Application.ScreenUpdating = True26    MsgBox "Failed: " & Err.DescriptionvbCritical27End SubImmediate — runningRefreshBudget?RefreshBudget › Loaded 218 transactions from 'Transactions' › Categories matched: 12 / 12 › Savings goals recalculated (6 goals) › Trend chart rebuilt in 42 ms Done. 0 errors, 0 warnings.ReadyLn 24, Col 5

Project screenshots

Code preview

Syntax-highlighted VBA — first 14 lines unlocked. Upgrade to view the full project.

dashboard-automation.bas
VBA
1Option Explicit
2 
3' Dashboard Automation — refresh every PivotTable + chart on the
4' "Dashboard" sheet and export a snapshot PNG for the daily report.
5 
6Public Sub RefreshDashboard()
7 Dim wb As Workbook, ws As Worksheet
8 Dim pt As PivotTable, ch As ChartObject
9 Dim snapshotPath As String
10 
11 On Error GoTo Fail
12 Set wb = ThisWorkbook
13 Application.ScreenUpdating = False
14 Application.Calculation = xlCalculationManual
15 
16 wb.RefreshAll
17 DoEvents
18 
19 For Each ws In wb.Worksheets
20 For Each pt In ws.PivotTables
21 pt.RefreshTable
22 Next pt
23 Next ws
24 
25 Set ws = wb.Worksheets("Dashboard")
26 For Each ch In ws.ChartObjects
27 ch.Chart.Refresh
28 Next ch
29 
30 snapshotPath = wb.Path & "\Snapshots\" & Format(Now, "yyyymmdd_hhmm") & ".png"
31 ExportDashboardPNG ws, snapshotPath
32 
33 Application.Calculation = xlCalculationAutomatic
34 Application.ScreenUpdating = True
35 MsgBox "Dashboard refreshed. Snapshot: " & snapshotPath, vbInformation
36 Exit Sub
37Fail:
38 Application.Calculation = xlCalculationAutomatic
39 Application.ScreenUpdating = True
40 MsgBox "Refresh failed: " & Err.Description, vbCritical
41End Sub
Locked preview

Unlock XLFormula AI Pro to view the complete project source, download the .xlsm workbook, and generate custom VBA with AI.

Unlock with Pro

Key features

  • Refreshes every PivotTable and chart
  • PNG snapshot export for daily reports
  • Manual calculation mode + restore
  • Timestamped output folder
  • Failure-safe: always restores UI state

What's included

  • Dashboard Automation.xlsm
  • Sample multi-source dashboard
  • Snapshot folder scaffolding
  • Setup guide (PDF)
Included with Pro

Get this project — and every other one

Every download, every VBA project, every future release for $5.00/month.

  • AI VBA Generator
  • Download Projects
  • Complete VBA Library
  • Lifetime Updates
  • Premium Templates
  • Priority Support

Frequently asked questions

Does it work with Power Query?
Yes — RefreshAll picks up Power Query connections, PivotTables, and standard data connections.

Related projects