Excel Training

Recorded macro code

In the Visual Basic Editor program provided with Microsoft Excel, you can view the recorded macros code created automatically. You can also edit the macro code to perform another action. For example, instead of multiplying two numbers you could change the Excel macro code by replacing the '*' with a '/' and perform a division through the macro! The Excel training video depicts how easily you can check the macro code in the Visual Basic Editor.
  • Click on Tools
  • Select Macro, Macros...
  • Slect the recorded Macro
  • select 'Edit'
  • Now you can view the code of the recorded Excel macro in the VBA editor
  • The name of the macro is Macro1
  • The code lines with an apostrophe and green colored are known as remarks
  • The ActiveCell is the cell where your cursor is and where you wrote '=B2*C2' which is indicated in the macro by 'FormulaR1C1'. R stands for row and C for column
  • RC[-2] stand for B2 and represents a cell in the same row as the formula cell but 2 columns to the left. RC[-1] denotes a cell address in the same row but one column to the left. RC[-2]*RC[-1] = B2*C2.
  • Range("D3").Select means your cursor is now in cell D3 which happens after you press enter after writing the formula in cell D2.
Additional reading on modifying code of a recorded macro in Excel
How to modify a recorded macro
How to fix a recorded macro

Recorded macros code