Object Members & the Object Browser (Exercise)
ฝัง
- เผยแพร่เมื่อ 5 ก.พ. 2025
- VBA Fundamentals: Video 8
Link to Exercise File: drive.google.c...
-------------------------TOPICS-----------------------
INTRODUCTION TO OBJECT MEMBERS
The video covers using the appropriate methods, properties, sub-objects and events for each object. These things can be used by an object (methods, properties, events, etc.) are all called the object's "members".
EXAMPLES OF OBJECTS AND THEIR MEMBERS
• Worksheets.Add
• Worksheets.Delete
• Rows.Insert
• Rows.Delete
• Columns.Insert
• Range.Value
• Worksheets.Rows.Insert
EXPLICIT CODE STATEMENTS
We recommend using "explicit code notation" in order to specify where each statement should happen. Example: rather than using
• Rows(1).Insert
use:
• Worksheets(1).Rows(1).Insert
OBJECT BROWSER
How to find the many other members that exist for a given object:
1. Tooltip that appears after typing an object name, followed by "." in the Code Window
2. Object Browser - how to search for object members
EXERCISE
Create a macro that:
1. Clears cells B1 and B2
2. ClearFormats from cell H2
3. ResetAllPageBreaks on current sheet
4. Copy cell A2 (don't paste it, just copy it)