Good day all
I note that the more experienced practitioners will create an object such as oMyWksht and then after setting it equal to WorksheetA, interrogate oMyWksht instead of interrogating WorksheetA.
The advantages of this approach escape me. Any guidance will be appreciated.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Benefits of creating an object (VBAExcel)
Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Benefits of creating an object (VBAExcel)
- This topic has 9 replies, 6 voices, and was last updated 20 years, 3 months ago.
AuthorTopicDon Wells
AskWoody LoungerMarch 11, 2005 at 1:10 pm #416959Viewing 0 reply threadsAuthorReplies-
WScharlotte
AskWoody LoungerMarch 11, 2005 at 1:19 pm #934074Using an object variable improves the code performance because you don’t have to keep rereferencing the object itself. Otherwise, VBA has to validate each reference back to WorksheetA and this slows things down. When you instantiate an object reference (Set MyObject = ObjectA), the variable holds on to the valid reference, so the engine doesn’t need to do any extra work on it.
-
Don Wells
AskWoody Lounger -
WSGary Frieder
AskWoody LoungerMarch 12, 2005 at 9:50 am #934311Don,
Another practical benefit is that by declaring the worksheet object, you then have access to intellisense when developing the code.
For example, if you type “Worksheets(“Sheet1″)” and then type a period, you won’t get the automatic list of class members.
But if you use:
Dim oWorksheet As Worksheet
Set oWorksheet = Worksheets(“Sheet1”)
oWorksheet– if you then type a period after “oWorksheet”, the intellisense will kick in. Someone more versed in Excel may be able to explain better, but if I understand it correctly, the reason intellisense doesn’t work in the first example, but does in the second, is that there are a number of worksheet types in Excel, each of which has its own specific list of class members.
The first code example references the generic Worksheets object; listing the members isn’t possible because the worksheet Type isn’t specified. Although I’m not sure of the exact mechanism, when you set an object reference to a specific worksheet, somehow the information about the Type of that worksheet, is included in the new object’s properties, therefore the list of members for that type of worksheet can be displayed.
Gary
-
Don Wells
AskWoody Lounger -
H. Legare Coleman
AskWoody Plus -
Don Wells
AskWoody Lounger -
WSJohnBF
AskWoody Lounger
-
-
-
WSpieterse
AskWoody Lounger -
WSGary Frieder
AskWoody LoungerMarch 13, 2005 at 6:48 am #934421
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
EchoLeak : Zero Click M365 Copilot leak sensitive information
by
Alex5723
51 minutes ago -
24H2 may not be offered June updates
by
Susan Bradley
1 hour ago -
Acronis : Tracking Chaos RAT’s evolution (Windows, Linux)
by
Alex5723
13 hours, 25 minutes ago -
Turning off OneDrive
by
CWBillow
17 hours, 54 minutes ago -
June 2025 updates are out
by
Susan Bradley
34 minutes ago -
Mozilla shutting Deep Fake Detector
by
Alex5723
1 day, 4 hours ago -
Windows-Maintenance-Tool (.bat)
by
Alex5723
13 hours, 33 minutes ago -
Windows 11 Insider Preview build 26200.5641 released to DEV
by
joep517
1 day, 6 hours ago -
Windows 11 Insider Preview build 26120.4250 (24H2) released to BETA
by
joep517
1 day, 6 hours ago -
Install Office 365 Outlook classic on new Win11 machine
by
WSrcull999
1 day, 6 hours ago -
win 10 to win 11 with cpu/mb replacement
by
aquatarkus
22 hours, 35 minutes ago -
re-install Windows Security
by
CWBillow
1 day, 10 hours ago -
WWDC 2025 Recap: All of Apple’s NEW Features in 10 Minutes!
by
Alex5723
1 day, 13 hours ago -
macOS Tahoe 26
by
Alex5723
1 day, 7 hours ago -
Migrating from win10 to win11, instructions coming?
by
astro46
58 minutes ago -
Device Eligibility for Apple 2026 Operating Systems due this Fall
by
PKCano
22 hours, 26 minutes ago -
Recommended watching : Mountainhead movie
by
Alex5723
23 hours, 11 minutes ago -
End of support for Windows 10
by
Old enough to know better
6 hours, 42 minutes ago -
What goes on inside an LLM
by
Michael Covington
17 hours, 20 minutes ago -
The risk of remote access
by
Susan Bradley
33 minutes ago -
The cruelest month for many Office users
by
Peter Deegan
1 hour, 11 minutes ago -
Tracking protection and trade-offs in Edge
by
Mary Branscombe
1 day, 3 hours ago -
Supreme Court grants DOGE access to confidential Social Security records
by
Alex5723
2 days, 12 hours ago -
EaseUS Partition Master free 19.6
by
Alex5723
1 day, 12 hours ago -
Microsoft : Edge is better than Chrome
by
Alex5723
3 days, 1 hour ago -
The EU launched DNS4EU
by
Alex5723
3 days, 14 hours ago -
Cell Phone vs. Traditional Touchtone Phone over POTS
by
280park
3 days, 4 hours ago -
Lost access to all my networked drives (shares) listed in My Computer
by
lwerman
3 days, 19 hours ago -
Set default size for pasted photo to word
by
Cyn
4 days, 1 hour ago -
Dedoimedo tries 24H2…
by
Cybertooth
3 days, 13 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.