πŸš€ New batches open: Advanced Excel β€’ Power BI β€’ SQL β€’ AI for Analytics β€” Book a free demo

Free VBA Tutorial β€” learn Excel macros in 12 days

Loops, ranges, functions and formatting - topic by topic, with every macro runnable right here in the page against a real worksheet.

A free, hands-on VBA course

Twelve short lessons that take you from never having opened the Visual Basic Editor to writing a macro that builds a report on its own. Every macro runs in your browser against a real worksheet - edit it, break it, run it again. Nothing to install, no signup, and you do not even need Excel in front of you.

Start with Day 1.

Who this is for Anyone in MIS, finance, operations or reporting who does the same Excel job every week and knows there must be a better way. No programming background is assumed - Day 1 starts at Alt + F11.

The 12 days

Day 1 β€” What VBA is, and your first macro

VBA is how you stop doing the same Excel job by hand every week. Day one is the whole shape …

Day 2 β€” Variables, types and Option Explicit

A variable is a named box. Getting the name and the type right is most of what separates cod…

Day 3 β€” Cells, Range and Offset

Two ways to point at a cell, and knowing which to use when is what makes a macro readable.…

Day 4 β€” If, ElseIf and Select Case

Code that always does the same thing is a formula. Code that decides is a macro.…

Day 5 β€” For loops - doing it to every row

This is the day VBA starts earning its keep. One loop replaces an afternoon of dragging form…

Day 6 β€” The last row, Do loops and For Each

Hard-coding row 17 works until somebody adds row 18. This is the day your macros stop breaki…

Day 7 β€” Text functions - cleaning messy data

Most of the data you will ever automate arrives dirty. These eight functions fix nearly all …

Day 8 β€” Numbers, rounding and dates

Two things break reports more than anything else: a rounding rule nobody checked, and a date…

Day 9 β€” Subs, Functions and arguments

One 200-line Sub is a nightmare to fix. Six small ones that each do one thing is a program y…

Day 10 β€” Arrays, and why they make macros fast

This is the difference between a macro that takes four minutes and the same macro taking und…

Day 11 β€” Formatting, With blocks and WorksheetFunction

The calculation is only half the job. A report nobody can read gets sent back.…

Day 12 β€” Practice questions and interview answers

Everything from the first eleven days, as problems. Try each one before you look.…

The worksheet everything runs against

Sixteen orders in A1:G17. Column H is deliberately empty - filling it is the first real job you will do, on Day 2.

What this playground can and cannot do

The VBA language is a language, so it runs here for real. The interpreter is written from scratch and handles variables and types, If / ElseIf / Select Case, For / For Each / Do / While loops with Exit, Subs and Functions with arguments including ByRef and ByVal, one- and two-dimensional arrays, and the string, number and date functions you use every day.

The worksheet is real too: Cells and Range, .Value, .Offset, .Resize, .End(xlUp), .Rows.Count, .Font.Bold, .Interior.Color, .NumberFormat, With blocks, and WorksheetFunction for Sum, Average, Max, Min, Count, CountA, CountIf, SumIf, Round, Proper and VLookup. Reading a block into a 2-D array with arr = Range("A2:G17").Value works, and so does writing one back.

After each run the sheet is redrawn with every cell your macro changed outlined in gold, so you can see exactly what happened.

Not covered Recording macros, the Visual Basic Editor itself, buttons and form controls, UserForms, opening and saving other workbooks, PivotTable and Chart objects, events, and error handling with On Error. Those need Excel in front of you and somebody to ask - that is the classroom course. What you get here is the part people actually get stuck on: writing the loop and getting the right number out.

How to get the most out of it

  1. Type the code, do not copy it. The typing is where the learning happens, and the typos teach you to read error messages.
  2. Change something and run it again. Every box is editable. Break it on purpose.
  3. Watch the gold cells. If your macro changed a cell you did not expect, find out why before moving on.
  4. Do the exercises at the end of each day before you go to the next one.