[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

What control would I use to get chart selection?

Posted on 2011-03-04
8
Medium Priority
?
281 Views
Last Modified: 2012-05-11
I'm writing an addin, where the user has to select a chart, and then select a range (two different entries).  What control would I use on a userform to enable the user to select a chart (and get that value - e.g., "Chart 1" on a particular sheet - or for that matter, an active chart on a chart sheet?

Thanks!

Dave
0
Comment
Question by:dlmille
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35039146
You can pop up a message telling the user to select a chart and after that you can use the selection object to interact with the chart?

Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35039149
For selecting different Range, you can use the RefEdit Control.

Sid
0
 
LVL 42

Author Comment

by:dlmille
ID: 35039150
Possibly - since this is top of mind for you, how would I test the selection to ensure it was a chart they had selected?

Dave
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35039191
You can use the TypeName(Selection)

Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35039383
Example

'~~> Checks if selection is a valid chart
Sub Sample()
    On Error GoTo Err
    If TypeName(Charts(Selection.Parent.Name)) = "Chart" Then _
    Debug.Print "You have selected a Chart Sheet"
Err:
    If TypeName(Selection) = "ChartArea" Then
        Debug.Print "You have selected a Chart in a Sheet"
    Else
        Debug.Print "Invalid Selection"
    End If
End Sub

Open in new window


Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35039396
Forgot the exit sub before Err:

Sid
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 2000 total points
ID: 35039470
And to check for the Chart Type.

'~~> Checks if selection is a valid chart
'~~> Also Check for the Chart Type
Sub Sample()
    On Error GoTo Err
    If TypeName(Charts(Selection.Parent.Name)) = "Chart" Then
        On Error GoTo 0
        Debug.Print "You have selected a Chart Sheet"
        Debug.Print "Chart Type :" & ActiveChart.ChartType
    End If
    Exit Sub
Err:
    If TypeName(Selection) = "ChartArea" Then
        Debug.Print "You have selected a Chart in a Sheet"
        Debug.Print "Chart Type :" & ActiveChart.ChartType
    Else
        Debug.Print "Invalid Selection"
    End If
End Sub

Open in new window


Sid
0
 
LVL 42

Author Closing Comment

by:dlmille
ID: 35039515
Thanks again!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question