Learnr

Learn Excel VBA

Turn repetitive spreadsheet work into a button that does it for you.

or browse all courses.

Free to start. Built from a single prompt. No credit card.

VBA, Visual Basic for Applications, is the programming language built into desktop Microsoft Office. In Excel it lets you automate repetitive tasks, such as formatting a weekly report, combining files or cleaning imported data, and add custom worksheet functions. You write code in the Visual Basic Editor and control Excel through its object model: the Application holds Workbooks, which hold Worksheets, which hold Ranges. The macro recorder gives you working code to study from day one. Learnr builds a personalized Excel VBA course from your prompt and teaches it through short, interactive lessons.

How to learn Excel VBA, step by step

  1. Turn on the Developer tab and record a macro. Enable Developer in Excel's ribbon options, record yourself formatting a table, then press Alt+F11 to open the Visual Basic Editor and read the generated code. Save as .xlsm so the macro is kept with the file.
  2. Learn the object model. Practice Workbooks("Sales.xlsx").Worksheets("Jan").Range("A1"), Cells(row, column), and properties like Value, Formula and Font.Bold. Use the Immediate window and the Locals window to inspect objects as your code runs.
  3. Clean up recorded code. Recorded macros are full of Select and Activate calls. Rewrite them to act on ranges directly, like Range("A1:D1").Font.Bold = True, which runs faster and does not depend on what happens to be selected.
  4. Add logic with variables and loops. Put Option Explicit at the top of every module and declare variables with Dim. Loop through rows to find the last used row, flag values above a threshold, or copy matching records to another sheet.
  5. Write user-defined functions and handle errors. Create a Function that calculates something your formulas cannot easily express and call it from a cell. Add On Error handling and clear messages so a missing sheet does not crash the whole macro.
  6. Automate a real weekly task. Pick a report you build by hand and automate it end to end, then attach it to a button. A few minutes of Learnr practice each day keeps object model syntax and loop patterns fresh.

What you'll learn

  • Record, run and edit macros in the Visual Basic Editor
  • Reference workbooks, worksheets, ranges and cells in code
  • Use variables, If statements and For Each loops
  • Write custom functions you can call from worksheet formulas
  • Automate a full report with error handling and a button

What's inside your Excel VBA course

A sample path Learnr builds for Excel VBA. Your real course adapts to your goal and level.

  • 1. The Developer tab, macro recorder and VBA editor
  • 2. The Excel object model and working with ranges
  • 3. Variables, data types, conditions and loops
  • 4. Procedures, functions and user-defined functions
  • 5. Events, user forms and error handling
  • 6. Speed, security and building a reusable automation

How long does it take to learn Excel VBA?

Recording and lightly editing macros takes a few days. Writing your own procedures with loops, variables and the object model takes about 3 to 6 weeks at a few hours a week, and robust automations with forms and error handling take a few months.

What you need before you start

Solid everyday Excel skills, including formulas, cell references and tables. Desktop Excel on Windows works best; the Mac version supports VBA with some limits, and Excel for the web does not run VBA.

Common mistakes to avoid

  • Keeping the Select and Activate lines from recorded macros. Reference ranges directly so code runs faster and does not break when another sheet is active.
  • Skipping Option Explicit, which lets a typo silently create a new empty variable. Turn on Require Variable Declaration in the editor options.
  • Enabling macros in files from unknown senders. Macros can run harmful code, so only enable them in workbooks you trust.

How Learnr builds your course

Type your topic

Tell Learnr you want to learn Excel VBA, or get as specific as you like.

Get a personalized course

Learnr instantly builds a full Excel VBA course tailored to your goal and skill level.

Learn and level up

Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.

Excel VBA questions, answered

Is VBA still worth learning?

For desktop Excel automation, yes: many workplaces rely on existing VBA macros. Office Scripts, written in TypeScript, and Power Query cover some of the same ground for Excel on the web and data cleaning, so it helps to know when each fits.

Do I need to know programming to learn VBA?

No. Many people learn VBA as their first language because the macro recorder gives working examples. Learnr starts from the basics and builds up to loops and functions at your pace.

Explore more courses

More programming and tech courses

See all programming and tech courses

Ready to learn Excel VBA?

Start your free, personalized Excel VBA course in seconds. .