What is VBA Programming?
Visual Basic for Application is a programming language for Microsoft Excel and other office application ex. Access, Outlook, Word, PowerPoint. VBA is an object-based programming language.
VBA has many features of Object Oriented Programming Language so there are available different types of Class, Object, Property, and Method available in VBA Programming Language, which is used while writing code.
Class – Class is a collection of the same type of objects. When we define a class it just creates a template. When we create a class it does not occupy memory. Memory is occupied only by objects.
Example of Class – Workbook, Worksheet, Range, Cells, Chart, Pivot Table and many more.
Object – An object is an element of an application, representing an instance of a class. Objects only occupied memory in space.
Example of Object – Book1, Sheet1, Range(“A1:A10”), Cells(1,1), Chart 1, Pivot Table 1.
Property – Property is the attributes of objects. It represents information stored in an object.
Example of Property – Height, Width, Color
Method – A method is a Sub or Function, Which perform on Object. A Method is changed by Object Properties.
Example of Method – Add, Delete, Activate, Printout, Print Preview and many more.
Suppose we have to do lots of work in Excel i.e consolidate data from multiple worksheets in a single worksheet, import data into excel from SQL Server, import data into excel from MS Access, Creating Word Document, Import multiple files Name into Excel from folders and subfolders, Rename folder files, Insert object into excel, and lots of works to do then we use VBA. VBA has many features to help us to work fast and accurate i.e. loops, functions, library.
We cannot use VBA in-depended because it is hosted with Excel and other Office Application, we have to always access these applications for using VBA.
What is VBA Programming?
Writing Code Place
We write code in VBE (Visual Basic Editor). There is 5 place available for coding for every single workbook.
- Standard Module
- Form Module
- Class Module
These are VBE, where we write code.
How to Access VBE first time for Excel.
- Go To File Tab
- Customize Ribbon
- Then Check Developer Option in Customize Ribbon
- Then Click Ok
Save Macro-Enabled Excel File
We save Macro-Enabled Excel File in different Extension.
- .xlsm – Macro-Enabled Extension
- .xlsb – Binary File
- .xsl – Excel 1997 – 2003
- .xltm – Macro Enable Template File
- .xlt – Excel 1997 – 2003
- .xlam – Macro-Enabled Add-in
- .xla–Excel 1997 – 2003
These all valid formats for saving Excel Macro File. .xlsx is an invalid format for saving Excel Macro File.