Friday, August 6, 2010

Working with Microsoft Excel Objects,Properties and Methods

The definition given by Microsoft for:
  1. 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.
  2. 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.
  3. 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.
I think the above explanations is clear and easy to understand but don’t worry you will be able to understand when you continue try and error. The more you record the more you understand the coding. To be more clear understand refer below code and try by yourself.
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

No comments:

Post a Comment