Excel Macro Recorder


This entry is part 2 of 9 in the series Excel VBA

A quick way to get started programming in Excel is to use the Macro Recorder. You can start the recording and just work with Excel as you normally would and stop the recording. You will then be able to edit the code that the recorder created and begin to learn how to write VBA code. I recommend starting with short and simple examples.

Simple Example

Here is the results of a very simple macro being recorded and the VBA code generated. I added two lines of comments explaining what I did during the recording. I gave the macro a name VBAIsFun. The macro user has selected cell B12 and then they ran the macro by going to the Developer tab, clicking Macros and selecting the VBAIsFun macro and clicking the Run button. There is one concern with this macro because it moves the cursor to cell B13. To fix it, I simply removed the Range(“B13”).Select line of code.

Sub VBAIsFun()
'
' VBAIsFun Macro
' Reorded as user in cell B12 and
' typing VBA is Fun! and pressing the Enter key

'
    ActiveCell.FormulaR1C1 = "VBA is Fun!"
    Range("B13").Select
End Sub

You can use the macro recorder at first to learn about VBA programming, but to become an advanced programmer you will need to learn how to code from scratch.

Series Navigation<< Excel VBA IntroductionExcel Entering Text with VBA >>