Results 1 to 2 of 2
  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 Excel

  2. #2
    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)

    Never mind, 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.

Posting Permissions

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