Results 1 to 6 of 6
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Charts count inside a sheet (VBA/Excel)

    Here goes another stupid question... [img]/forums/images/smilies/sad.gif[/img]

    I'm trying to count the number of charts inside a sheet.
    There is a method called oSheet.ChartObjects where I can get each chart. However I don't how many!
    There is another property called Excel.Workbook.Charts.Count that could work. Unfortunately, I need to know the number of charts for each Sheet, not for the whole Workbook.

    Any idea?

    Thanks

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Charts count inside a sheet (VBA/Excel)

    Try:

    oSheet.ChartObjects.Count

    That should do it for you.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Charts count inside a sheet (VBA/Excel)

    Thanks for your answer, but that property doesn't exist.

    ChartObjects is a method not a property

  4. #4
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Charts count inside a sheet (VBA/Excel)

    In XL2K, it isn't in the intellisense list, but it does work.

    Have a look at the attached workbook.
    Attached Files Attached Files
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Charts count inside a sheet (VBA/Excel)

    Hi,
    Bryan is correct - the ChartObjects method can either return a single chartobject or the chartobjects collection, which does have a Count property.
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Charts count inside a sheet (VBA/Excel)

    sorry guys... you're right. I mess up with so many properties and I didn't see this the first time that I tried it

    Thanks!

Posting Permissions

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