• Why does the SELECTION object not show in Immediate Window

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Why does the SELECTION object not show in Immediate Window

    Author
    Topic
    #462959

    EXCEL: 2003

    Does anyone know why within the Immediate Window, when typing the SELECTION object, the intellisense pop-up window that appears for other object like active Activecell, does not appear/pop-up?

    When I type the following:

    ?ActiveCell.

    The intellisense/pop=up shows the available objects within the ActiveCell object. But when I type the same for selection like this

    ?Selection.

    Nothing pops up. ANyone know why?

    Important Note: I do have both Excel 2003 & 2007 installed. I mention this just in case this is something known to be a problem between multiple versions of Excel.

    thanks

    Viewing 1 reply thread
    Author
    Replies
    • #1180012

      This is a complete guess, but I suspect it is because the Selection could be a cell, or a range of cells, or a picture, or a chart, etc. and each of these would have different properties and methods.

    • #1180023

      Stuart is correct – it is because the Selection can be different types of objects, so IntelliSense can’t predict what properties and methods it will have when the code is run.

      Similarly, if you type

      ActiveSheet.

      IntelliSense won’t kick in because the active sheet could be a worksheet or a chart sheet (or even an old-fashioned macro sheet or dialog sheet, but you hardly encounter those any more).

      • #1180035

        Thanks guys for the feedback. You confirmed what I suspected but I was hoping I was wrong. I don’t have the VBA-Excel model memorised and so I rely heavy on intellisense.

        It would be nice if the intellisense,. when it ran into this kind of issue would popup still and let you select what obect ype you want and then go from there.

        • #1180048

          It would be nice if the intellisense,. when it ran into this kind of issue would popup still and let you select what obect ype you want and then go from there.

          That would indeed be nice, but I fear that the probability that Microsoft will implement it (in the VBA editor at least) is negligible.

        • #1180067

          The best way around it is to not use Selection, but to create a variable of the appropriate type and set the selection to that variable, then you can use that variable with intellisense…

          Steve

          • #1180068

            The best way around it is to not use Selection, but to create a variable of the appropriate type and set the selection to that variable, then you can use that variable with intellisense…

            Steve

            WIthin the immedaite window? Woudln;t doing that require adding/inserting a module?

            • #1180070

              WIthin the immedaite window? Woudln;t doing that require adding/inserting a module?

              Yes, that would require creating a macro in a module.

              In the Immediate window, you could use

              Range(“A1:C10”).

              instead of Selection if the selection is a range, for example. But the Immediate window has limited functionality compared to a module.

    Viewing 1 reply thread
    Reply To: Why does the SELECTION object not show in Immediate Window

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: