Solved

What control would I use to get chart selection?

Posted on 2011-03-04
8
279 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

705 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