What is the use of functions, properties and methods in VBA

What is Object Oriented Programming?

If you are not related to programming, this term must sound like Chinese words. Object Oriented Programming (OOP) is a programming paradigm that uses objects to interact. A file Excel is full of objects that can be set in hierarchies e so that can act, it is necessary to modify the methods and properties of the objects.

Using functions, properties and methods in VBA

Within the Excel application objects are the things that can be manipulated, for example: a workbook, a sheet and a cell are Excel objects. Alone Excel has more than 200 objects organized in hierarchies, which means that an object can contain other objects.




What is the use of functions, properties and methods in VBA

All elements in Excel are an object, workbook, chart, pivot table, and so on. All objects have properties, which are the characteristics that define the object, and methods, which are the actions the object can perform.

Put simply, the properties are the characteristics of the objects and methods are the actions they can perform. Applying this example in real life, a cell phone can be an object, the property of the cell phone would be the color it has and one method would be to make a call.

Properties in VBA

All the objects have their own properties or characteristics that describe it. These attributes define the appearance of the object, its size, color, position on the screen and its overall appearance.

In VBA, to assign the value to a property, you have to follow the object reference with a period, the name of the property and then an equal sign (=). The syntax should be as follows:




Object.property = attribute 

Some properties can also be objects. As would apply in case you want to change the font of the Range object, you need to use the Font property. Since fonts have different characteristics such as size and shape, other properties apply.

Metodi in VBA

The properties tell the object how it should look now the methods indicate how it should behave. The method is the action that the object can perform in Excel. The syntax for implementing a method is as follows:

Object.Method

Some methods allow for more complex arguments which are parameters for specific actions that an object must perform.

Functions in VBA

Functions execute code programmed within the application to give a value as a final result. Functions require one or more variables for multiple operations to internalize and display a result.  Excel already has more than 400 programmed functions, some are known as MEAN or SUM which are used to perform simple arithmetic operations.



How to enable macros in Excel 2016

If you can't find the developer options on the toolbar, it's because they are hidden. To activate them and show them from now on you have to click on File menu and then on Options.

What is the use of functions, properties and methods in VBA

Select the Customize Ribbon option. Two boxes appear showing the main tools (left) and the main tabs (right). The Scheduler option must be disabled, select it and press the accept button. From now on, the Programmer ribbon available should appear.


A quick way to do this is to right-click on any empty spot on the ribbon and select the Customize option quick access toolbar and then Customize bar Multifunction.


add a comment of What is the use of functions, properties and methods in VBA
Comment sent successfully! We will review it in the next few hours.