: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/content/94/10002394/html/tips.php
on line 336
Excel Tips Tutorial: How to Enter Credit Card Numbers In Excel
Excel Tips Tutorial: How To Make Gantt Chart in Microsoft Excel
Excel Tips Tutorial: Pivot Tables
Excel For Noobs Tutorial: How to use IF function for logical calculation
Excel For Noobs Tutorial: How to use data filtering in MS Excel
Excel Tips Tutorial: How to Use Concatenate Function to Join Cells Together
Excel For Noobs Tutorial: How to create graphs in Excel
Excel Tips Tutorial: How to Insert Cells in Data Tables in MS ExceI
Excel Tips Tutorial: How to Convert Values From One Measurement System to Another
Excel Tips Tutorial: How to Convert Numbers to Text
Excel Tips For Noobs: How To Add Diagonal or Crossed Lines to a Cell
Excel Tips Tutorials: How to Make A Pie Chart in Microsoft Excel
Excel Tips: How to Solve Circularity Errors With Iterations
Excel Tips Tutorial: How To Use Vlookup in Microsoft Excel
Excel Tips Tutorial: How to use SUMIF, COUNTIF and AVERAGEIF Functions in Microsoft Excel
Excel Tips Tutorial: How to Use Conditional Format in Microsoft Excel
Excel Tips Tutorial: How to Connect Links to Excel Worksheets
Excel Tips Tutorial: How To Write Formulas In Excel
Excel Tips Tutorial: How to Find and Replace Values in Microsoft Excel
Excel Tips Tutorial: VBA Visual Basic for Application For Beginners in Microsoft Excel
Excel Tips Tutorial: How to Use Trim, Upper, Lower and Proper In Microsoft Excel
Excel Tips Tutorial: How to Convert a PDF File to Editable Excel File
Excel Tips Tutorial: How to Use Pivot Tables in Microsoft Excel
Excel Tips Tutorial: How to Find and Select Content or Cells in Excel
Excel Tips Tutorial: How to Merge Styles and Themes of Old and New Excel Versions 2003 2007 2010 2013
Excel Tips Tutorial: Microsoft Excel Keyboard Shortcuts
Excel Tips Tutorial: How to Draw a Line Through a Word in Excel - Strikethrough
Excel Tips Tutorial: Horizontal Text Alignment in Excel (General, Left, Center, Right, Fill, Justify, Center across Selection and Distributed)
Excel Tips Tutorial: Vertical Alignment in Excel (Top, Center, Bottom, Justify, and Distributed)
Excel Tips Tutorial: How to Display Text at a 45 Degree Angle (Diagonal Text)
Excel Tips Tutorial: How to add a Background Image (Picture) to an Excel Worksheet
Excel Tips Tutorial: How to Use Format Painter to Copy and Paste Cell Formats
Excel Tips Tutorial: How to Use Cell Styles to Format Cells
Excel Tips Tutorial: How to Change the Default Style of an Entire Excel Workbook Using Cell Styles
Excel Tips Tutorial: How to Create Your Own New Cell Style in Excel
Excel Tips Tutorial: Understanding and Applying Themes in Excel
Excel Tips Tutorial: How to Pin Important Excel File to the Recent Files List
Excel Tips Tutorial: How to Add Folders to the Favorites List in the Open Dialog Box
Excel Tips Tutorial: How to Save Excel Workbook Files
Excel Tips Tutorial: How to Change the Default File Type to Save Excel Workbooks
Excel Tips Tutorial: How to Open and Recover an Unsaved Excel File
Excel Tips Tutorial: Rules for Filenames in Microsoft Excel
Excel Tips Tutorial: How to Print Only an Excel Chart without Printing out the Entire Worksheet
Excel Tips Tutorial: How to Remove Formula Error-Checking Smart Tags
Excel Tips Tutorial: How to Stop Automatically Creating Calculated Columns in Excel Tables
How to Name an Excel Table
Excel 2013 Tutorial: How to Refer to a Named Cell as a Constant
Excel Concatenate Function Tutorial - How to Join Text in Excel
How to Use If Else If Function in Excel 2013 - Nested If Function in Microsoft Excel
Excel Worksheets Tutorial for Microsoft Excel 2013
Absolute, Relative and Mixed Cell Reference Excel Tutorial
Excel 2013 Tutorial Creating and Opening Workbooks in Excel 2013
Excel 2013 Tutorial The Function Library
How to Share Workbooks in Excel 2013 Tutorial
Save and Save As Excel 2013 Tutorial
How to Recover Unsaved Files in Excel 2013 with the Auto Saved Feature
How to Export Excel Files to PDF Other Different File Types
Basic Excel 2013 Functions Tutorial
Excel Tutorial How to Use Nested Functions
How to Use GoTo Special in Microsoft Excel 2013 Tutorial
Excel Page Layout Tutorial
Microsoft Excel Tutorial Page Breaks, Headers and Footers
Excel 2013 Tutorial How to Format Fonts in Excel
How to Create a Custom List in Excel Tutorial
Data Validation Microsoft Excel 2013 Tutorial - How to Restrict Entering Data in a Cell
Understanding Excel Charts Tutorial
How to Create a Basic Chart in Excel Step by Step Tutorial
How to Create and Use a Pivot Table in Microsoft Excel 2013 - Excel Pivot Table Tutorial
How to Pivot Data with Excel Pivot Tables Tutorial
How to Create a Macro in Microsoft Excel 2013
Microsoft Excel 2013 Worksheet Template Tutorial How to Create
Drop Down Lists Tutorial in Excel 2013
How to Reference Formulas and Data on other Excel Worksheets Worksheets Microsoft Excel 2013 Tutorial
Excel Data Forms Tutorial Microsoft Excel 2013
How to Insert Drawing Objects into your Excel Spreadsheets Microsoft Excel 2013 Tutorial
Excel LOOKUP Function Tutorial Microsoft Excel 2013
Excel Workbook and Worksheet Objects Tutorial
Excel Tutorial: Variables in Microsoft Excel Visual Basic Application (VBA)
Excel VBA Tutorial: If Then and Else Statement in Microsoft Excel (VBA) Visual Basic Application
Excel Events Tutorial: Visual Basic Application Evens in Microsoft Excel 2013
Excel Workbook and Worksheet Objects Tutorial
In this lesson we will tell you what the Objects in Excel Visual Basic Application are.
Introduction and Hierarchy of Objects
An object is instance of something that hold some properties. Like John is object of Human, which hold many common properties that most humans have. In Excel one object can contain another object, than further that object can contain another object.
Excel VBA Programming involves working with an object hierarchy. It might sound quite confusing but in till the end of this lesson you will fairly familiar with what objects are and how they work in Excel VBA.
In Excel, we can say parent of all objects is Excel itself, and we call it Application object. Application object contains other objects, for example, the workbook object (this can be any workbook you have created). The workbook object can contain other objects, such as the worksheet object. The worksheet object contains other objects such as range object.
We hope you have already know that how to create a Macro in Excel if not then please check our tutorial on How to Create a Macro. In that chapter we have shown how to run code by clicking on command button. We used the following line of code in that chapter.
Range("A1").Value = "Hello"
Let me elaborate that line for you. Range is and object and Value is its property, we are assigning a string value “Hello” to object. This Range object is Child of its parent object, let’s see full hierarchy.
Application.Workbooks("create-a-macro").Worksheets(1).Range("A1").Value = "Hello"
You can clearly understand now, that Application is an object and it is accessing its child object Workbooks and in brackets (“create-a-macro”) is name of workbook it is accessing.
Now Workbook object is accessing its child object Worksheets and passing worksheet number in brackets (1), now Worksheet object is further accessing Range object that is child of it.
What are the Collections
You have noticed that workbooks and worksheets both are plural, but why? Because they are collections. Workbooks collection contains all the workbook objects that are currently open. The worksheet collection contains all the worksheet objects in a workbook.
How to refer to member of a collection
You can refer any member of any collection by following three methods.
1. Using the worksheet name.
Worksheets("Sales").Range("A1").Value = "Hello"
2. Using the index number (1 is the first worksheet starting from the left)
Worksheets(1).Range("A1").Value = "Hello"
3. Using the CodeName.
Sheet1.Range("A1").Value = "Hello"
Note: to see CodeName of any workseet, open the Visual basic editor. You can access VB Editor by clicking on Developer tab.
In project Explorer, the first name is Codename and second name is the worksheet’s name.
In image above you can see Sheet1 is CodeName and mySheet in actual name of worksheet.
Referencing a worksheet using codename is safest way to refer any worksheet because CodeName always remains the same even if you change name of worksheet.
But if you want to refer any worksheet into another workbook this method will not work.
Properties and Methods
Now we will learn about some properties and methods of Workbooks and Worksheets collection. Properties are something which a collections holds and which describe that collection, while methods can perform some action with a collection.
We have already added a command button in our previous lesson, now we will perform some actions with that. Open VB Editor and write following line of code
This Add method will create new Workbook. If we use it like following
It will add new worksheet to collection of worksheets.
The Count property of the Worksheets collection counts the number of worksheets in a workbook. Write the following line in code.
Now close VB Editor to try if your applied property of method works, click on button. In our example we have applied Add Method for worksheets.
After clicking on Command button, a new worksheet will added.
This is how we can use Methods and Properties.