Macro are the simple programs using to automate tasks/operations on the excel. They are developed using the programing language "Visual Basic for Applications"(VBA). This based on Visual Basic. We can record macro on excel and use them later. You have to activate Developer Tab before you record a macro. If you Don't know how, Check my post about
"How to Enable Developer Tab"
Below table will be used to demonstrate the example for record macro.
Brand | Item | List Price | Discount | Selling Price |
Nike | Shoe | $111.99 | $111.99 | |
Nike | Socks | $21.99 | ||
Adidas | Shoe | $58.74 | ||
Adidas | Socks | $16.99 | ||
Reebok | Shoe | $26.59 |
Copy above table and paste to cell A1 on blank sheet.
Start Record Macro
- Select cell E2.
- Then click on "Record Macro" in Developer Tab.
- After that a new pop up window appears.
- Now you can change the name of macro and assign a shortcut key to launch this macro on later. For this example we set the macro name as "CopyMacro" and "Ctrl + Shift + A" as the shortcut key.
- Then click "OK". Now our macro is recording.
Record the Macro
Now we can simulate the actions to be recorded as the macro. Follow below steps to record a simple copy macro.
- Copy the cell E2 and paste it onto cell E3.
- Then Click on "Stop Recording" in developer tab to stop recording our macro.
- Done.
You have recorded the first ever macro recorded by you. Let's check how it's working.
Check the Recorded Macro
- Delete the cell E3
- Then enter the "Ctrl + Shift + A" to activate your macro.
Now you can see excel automatically copy cell E2 and paste into cell E3.
Relative References
If you properly inspect the Developer tab, you can see there is an option calling "Use Relative References".
What is the use of that? Follow bellow steps and see the difference.
- Select Use Relative References Option
- Then Select cell E2.
- Now click on "Record Macro" in Developer Tab.
- Then a new pop up window appears.
- Now you can change the name of macro and assign a shortcut key to launch this macro on later. For this example we set the macro name as "CopyMacroNew" and "Ctrl + Shift + B" as the shortcut key.
- Then click "OK".
- After that Copy the cell E2 and paste it onto cell E3.
- Then Click on "Stop Recording".
- Then enter the "Ctrl + Shift + B"
See the difference. This time excel copies whichever cell you are selected and paste it into the relative position.
No comments:
Post a Comment