Checking1

What is Objects in Excel VBA ?

What is Objects in Excel VBA ?

The Excel Application itself is a Object. As we know every thing is Object which is actionable. So MS Excel also have some Objects like workbook, worksheets, Range etc. We are listing some types of Objects below in MS Excel.

1. Application Object

In below image you can see when we write (Application. ) keyword in visual basic editor we got entire excel objects . We can use these all excel objects with Application. Object accordingly we are taking example of  Application.ActiveSheet.Range Object. 

A. Code

Sub Application_ActiveSheet()

Application.ActiveSheet.Range("A1").Value = 100

End Sub

B. Output

We click Run button for Run the written code. Refer Cell A1 we got result in value 100 in A1 Range.

2. Workbooks Object

In below image you can see when we write (Workbooks. ) keyword in visual basic editor we got entire excel objects . We can use these all excel objects with Workbooks.  Object accordingly we are taking example of  Workbooks.Add  Object. We can add new workbook using Workbooks.Add code.

Followus

A. Code

Sub workbook_object()

Workbooks.Add

End Sub

B. Output

We click Run button for Run the written code. We got a new Workbook created Name Book2.

3. Workbook Object

The workbook Object use to manage worksheets collections. For Active workbook we use ActiveWorkbook. Object use to work on Active workbooks. Here we taking example of  ActiveWorkbook.Save. Below code will save Active workbook.

A. Code

Sub workbook_object()

ActiveWorkbook.Save

End Sub

B. Output

We click Run button for Run the written code. Active workbook will be saved on default location.

4. Sheets Object

In below image you can see when we write (Activeworkbook.Sheets. ) keyword in visual basic editor we got entire excel objects related to Sheets Object. We can use these all excel objects with ActiveWorkbook.Sheets. Object accordingly. 

We are taking example of  ActiveWorkbook.Sheets.Add . We can Add new worksheet in active workbook using this Object.


A. Code

Sub Sheets_Object()
ActiveWorkbook.Sheets.Add(After:=ActiveWorkbook.Worksheets(Worksheets.Count), Count:=1, _
Type:=xlWorksheet).Name = "Newsheet"
End Sub

B. Output
We click Run button for Run the written code. New sheet added in Active workbook having Name (Newsheet)


5. Worksheet Object

Worksheet Object work with Worksheets of entire excel workbooks. We use Object Activeworkbook. for work with Active workbooks. Let;s see below example for Copy paste Data of Range("A1:B3") at Range("D4") .


A. Code

Sub Activeworkbook()
ActiveSheet.Range("A1:B3").Copy
ActiveSheet.Range("D4").Select
ActiveSheet.Paste
End Sub

B. Output
We click Run button for Run the written code. Range ("A1:B3") Data copy and pasted in Range("D4:E6").



6. Worksheets Object

In below image you can see when we write (Worksheets. ) keyword in visual basic editor we got entire excel objects related to Worksheets. Object. We can use these all excel objects with Worksheets. Object accordingly.

We are taking example of  Worksheets.Add . We can Add new worksheet in active workbook using this Object.


A. Code

Sub Activeworkbook()

Worksheets.Add

End Sub

B. Output

We click Run button for Run the written code. New sheet added in Active workbook having Name (Sheet3)

Followus

Thanks for visiting @ Bexpertadvexel.com Blogs

Click to Donwood Macro file Here




Click on the Link for Join us : Register_Course

We at BeXpert Advanced Excel offer state of the art Advanced Excel Coaching at Home. Even corporate professionals comes to us, for Advanced Excel Training in Gurgaon for the same state of the art database management education.

Other Services : We provide Automated Tools for reporting and analysis your business Data Automatically using some simple steps in User from and Command buttons.




You can place Your order on Fiverr bexpertadvexcel

No comments:

Post a Comment

Feel free to ask your questions regarding Ms Excel & VBA macros.

Featured Post

बहुभाषी ब्लॉगिंग को अनलॉक करना: आपकी संपूर्ण मार्गदर्शिका

बहुभाषी ब्लॉगिंग को अनलॉक करना: आपकी संपूर्ण मार्गदर्शिका (   Unlocking Multilingual Blogging: Your Complete Guide ) आज की जुड़ी हुई दुनिया ...

LearnVBAbigners