Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Silicon Valley, California, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA: Tell Which Series is Selected (Excel 2000, SR1)

    Hi Gang,

    A colleague wants my spreadsheet to allow him to select a series on a chart, then based on which series it is, perform some other tasks.

    With VBA, how can I tell if the selected object is a series (or belongs to a series, in case they select a single point ) and if so, which one (series)?

    Thanks!

    PS - I will also post in VBA

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: VBA: Tell Which Series is Selected (Excel 2000, SR1)

    As an old numbers guy I avoid Charts, but I pulled one up, clicked on a Series and in the immediate window entered:

    ?typename(selection)
    Series
    ?selection.name
    Gross Margin Yield

    VBA is hard enough, I don't touch Charts with it, but I HTH.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Silicon Valley, California, USA
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA: Tell Which Series is Selected (Excel 2000, SR1)

    Thanks, John,

    Actually I finally figured it out myself, as follows:

    <pre>Private Sub Chart_Select(ByVal ElementID As Long, ByVal Arg1 As Long, ByVal Arg2 As Long)

    If ElementID = xlSeries Then
    ' Arg1 is now the series index
    Call DoSomethingWith(Arg1)
    Else
    ' Ignore it
    End If

    End Sub ' Chart_Select
    </pre>


    Weirdly, the Excel instance I was working with wasn't responding to any events associated with the Chart, even though Application.EnableEvents was True. I quit, rebooted and tried again, successfully.

    Thanks for the interest.

Posting Permissions

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