+ Reply to Thread
Results 1 to 5 of 5

simple vba question

  1. #1
    Jonathan Cooper
    Guest

    simple vba question

    example
    Sub test2()
    'counts number of comments

    Dim cmnts As Long
    cmnts = ActiveSheet.Comments.Count
    MsgBox cmnts
    End Sub

    When I type

    activesheet.
    (Notice the period at the end)

    Why doesn't VBA then automatically show me the properties/methods of
    Activesheet?



  2. #2
    Bob Phillips
    Guest

    Re: simple vba question

    Because the activesheet could be a worksheet a chart sheet, etc., so it
    cannot know what to present, so it gives nothing.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Jonathan Cooper" <JonathanCooper@discussions.microsoft.com> wrote in
    message news:4357BECE-299D-4E9F-BBE6-84854013450B@microsoft.com...
    > example
    > Sub test2()
    > 'counts number of comments
    >
    > Dim cmnts As Long
    > cmnts = ActiveSheet.Comments.Count
    > MsgBox cmnts
    > End Sub
    >
    > When I type
    >
    > activesheet.
    > (Notice the period at the end)
    >
    > Why doesn't VBA then automatically show me the properties/methods of
    > Activesheet?
    >
    >




  3. #3
    Jonathan Cooper
    Guest

    Re: simple vba question

    Makes sense. When I started to type that, and nothing happened, I thougth
    that there was something wrong with what I was trying to do.

    thanks.

    "Bob Phillips" wrote:

    > Because the activesheet could be a worksheet a chart sheet, etc., so it
    > cannot know what to present, so it gives nothing.
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from email address if mailing direct)
    >
    > "Jonathan Cooper" <JonathanCooper@discussions.microsoft.com> wrote in
    > message news:4357BECE-299D-4E9F-BBE6-84854013450B@microsoft.com...
    > > example
    > > Sub test2()
    > > 'counts number of comments
    > >
    > > Dim cmnts As Long
    > > cmnts = ActiveSheet.Comments.Count
    > > MsgBox cmnts
    > > End Sub
    > >
    > > When I type
    > >
    > > activesheet.
    > > (Notice the period at the end)
    > >
    > > Why doesn't VBA then automatically show me the properties/methods of
    > > Activesheet?
    > >
    > >

    >
    >
    >


  4. #4
    Duke Carey
    Guest

    RE: simple vba question

    Bob's answer is correct. To get the prompts you want use a variable that has
    been DIMmed as a Worksheet, i.e.

    DIM ws As Worksheet

    then when you type "ws." you'll get the prompts you seek

    Duke

    "Jonathan Cooper" wrote:

    > example
    > Sub test2()
    > 'counts number of comments
    >
    > Dim cmnts As Long
    > cmnts = ActiveSheet.Comments.Count
    > MsgBox cmnts
    > End Sub
    >
    > When I type
    >
    > activesheet.
    > (Notice the period at the end)
    >
    > Why doesn't VBA then automatically show me the properties/methods of
    > Activesheet?
    >
    >


  5. #5
    Duke Carey
    Guest

    RE: simple vba question

    Oops, left out one part

    DIM ws as Worksheet
    Set ws = Activesheet



    "Jonathan Cooper" wrote:

    > example
    > Sub test2()
    > 'counts number of comments
    >
    > Dim cmnts As Long
    > cmnts = ActiveSheet.Comments.Count
    > MsgBox cmnts
    > End Sub
    >
    > When I type
    >
    > activesheet.
    > (Notice the period at the end)
    >
    > Why doesn't VBA then automatically show me the properties/methods of
    > Activesheet?
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1