What is macro in excel VBA?
- A macro is a set of actions that you can run as many times as you want.
- Theoretically, it is a set of code written in back end of Excel.
- We can save macro and run as many times as you want and whenever you want.
- Macros help you to save time on repetitive tasks involved in data manipulation and data reports that are required to be done frequently.
- VBA Macros use the Visual Basic Application in Excel to create custom user-generated functions and speed up manual tasks by creating automated processes.
- Macros are subroutines written in Visual Basic for Excel that can automate actions in a spreadsheet. They can either be coded directly in VBA by opening the Visual Basic window in Developer.
How to record macro?
- File —–> New and Save this file as . xlms (Marco enable format)
- Developer tab——–> Click On record macros
- Record macro dialog box will appear
Step 1.
- Name: – Daily_Record (Name of Macro)
- Store macros in —> Select this workbook
- Description—> Type some line about your macro like clear data. or coloring data
- Finally click on ok button
- Now types on excel sheet as you want to record content.
- Finally click on stop recording Marco.
Step 2
- Make a shape of any type
- Type name as you required
- Right click on shape and select assign macro
- Select macro you want to assign
- From macro in drop box select this work book
- Click on ok.
Step 3
- Now delete data form sheet (what you have recorded)
- And click on button you have created
- As you click it will added data what you have recorded even after deleting it.
Step 4
- Press Alt + F11 to open VBA Application File (Coding)
- Double click on macro to get code of program
- Click on first line of code (From module)
- Use F8 to check step by step compile of program
Same way creates another button like
- Cleardata
- colordata