2. Understand Excel VBA Macro

Lets us Edit our recorded Macro and Study it: So Go to View > Macros > click ‘View Macros’ and on Macro dialog box Select our ‘MyFirstMacro’ and Click on ‘Edit’ tab.

You can rename Macro by editing Macro name in From Sub Macroname()

Sub MyFirstMacro()

‘ MyFirstMacro Macro
‘ This is my First Macro.

‘ Keyboard Shortcut: Ctrl+f

Application.WindowState = xlNormal
Application.Left = 97
Application.Top = 43.75

ActiveCell.FormulaR1C1 = “Sr. No. ”
ActiveCell.FormulaR1C1 = “Name ”
ActiveCell.FormulaR1C1 = “Age”
ActiveCell.FormulaR1C1 = “1”
ActiveCell.FormulaR1C1 = “John ”
ActiveCell.FormulaR1C1 = “25”
ActiveCell.FormulaR1C1 = “2”
ActiveCell.FormulaR1C1 = “Alex”
ActiveCell.FormulaR1C1 = “30”
ActiveCell.FormulaR1C1 = “3”
ActiveCell.FormulaR1C1 = “Sam”
ActiveCell.FormulaR1C1 = “32”
End Sub

Our Macro name is first Green color line above , followed by our Description and Keyboard Shortcut.

Window State and position: 

You can define or change Window State and position on your monitor from Macro:

In our Macro WindowState was set to Normal.

Application.WindowState = xlNormal

Window Left and Top side distance as below:

Application.Left = 97

Application.Top = 43.75

If you want your Workbook to Open in Maximize and Minimized position then change xlNormal to xlMinimized or xlMaximized and Remove Application.Left and Application.Top

Press F5 or Run tab to see these changes.

Range(“A1”).Select : This line of code define Range of cells selected with mouse cursor. Here A1 is cell name.

ActiveCell.FormulaR1C1 = “Sr. No. ” : This line means we have clicked inside cell and activated it to write text “Sr. No.”

Same way it follows for rest cells data entry. Try changing text and cell numbers.

Delete Macro: 

You can delete macro from above Macro dialog box by selecting Macro name and Press delete.

Macro Options:

If you want to Change Shortcut key and Description then Select Macro and Press ‘Options…’ and change it.

Next 3. Excel VBA macro Options >>

Leave a Comment