- Object An object represents an element of Excel for examples workbooks, worksheets, range, cells and etc.Visual Basic actually object orientation programming language, nearly everything you do in Visual Basic involves modifying objects. There are four Excel objects you will work with more than any others: the Application object, the Workbook object, the Worksheet object, the Range object. The above sequences actually top to down object hierarchy.
- Properties A property is an attribute of an object or an aspect of its behavior, for example when we refer to Range object it should be border, fill color and etc.
- Methods A method is an action that an object can perform, for example when we refer to Range object action can perform should copy, cut and paste, delete and etc.
Option Explicit
Sub SelectOjectAndChangeProperties ()
Range("A1:A2").Select
Selection.Interior.ColorIndex = 3
End sub
The above code will select (Method) Range A1 and A2 (Object) and change Interior color index (Property) to red.
Copy the above into your modules and try it but don’t forget to enable your macro and set your security to medium.
Click here if you have any new project! Let us create for u for free.
Thanks
Sub SelectOjectAndChangeProperties ()
Range("A1:A2").Select
Selection.Interior.ColorIndex = 3
End sub
No comments:
Post a Comment