[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

Excel VBA Automatic help

Hi

I have been working with Excel VBA for a year now and am still not sure of why the automatic help seems to work sometimes and other times not.
By automatic help I mean typing in eg Application. and seeing a list box of certain options that you can choose from.

Are there any guidelines on how this works and how to get the most out of it.

Thanks



0
Murray Brown
Asked:
Murray Brown
1 Solution
 
jimbobmcgeeCommented:
Typically, if the object you are trying to get to is strongly-typed (early-bound), Intellisense will pop up the methods and members.  Often, some of these objects are just defined as Object, which have no direct members, but are set to a type, as required (late-bound).  In this case, you have to cast the Object-defined objects to their strongly-typed counterparts.  If you look at the Object Browser (F2), you can see which have been defined properly.  

For example:

    - ActiveCell is correctly defined as a Range and will use Intellisense to display the members
    - ActiveSheet, while technically containing all the methods of a Worksheet, is incorrectly defined as an Object; Intellisense will not work.

To rectify ActiveSheet, do:

    Dim oSheet As Excel.Worksheet
    Set oSheet = ActiveSheet

The Dim...As... command strongly types the variable, oSheet, as a Worksheet (with all the members available).  The Set command makes the strongly-typed oSheet point to the same memory as ActiveSheet (any changes to oSheet will reflect on ActiveSheet too).  Now you can do 'oSheet.' and all of ActiveSheet's members will pop up in Intellisense.

HTH

J.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks
Great in-depth answer!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now