I am creatin multiple charts on a single sheet. Lets say I have a sheet “Sheet 1” and on this sheet I am creating 10 charts with name from “chart 1” to “Chart 10”. But the problem is when I click the name box,list of all the charts is not available in that name box.
Can any one help me out how to do that through simple excel or excel VBA.
Update: I don’t believe anything other than range names or the currently selected object is available in the “name box”. The only alteration I have ever seen made to the name box is a width increase
In Xl2010 you can see all the charts using the Selection Pane
Home …. Editing …. Find & Select …. Selection Pane
Something like this would give you the list
Did you want the ability to select a chart from the list and activate it, or just the list itself?
Sub GetCharts() Dim chr As ChartObject Dim strOut As String For Each chr In Sheets(1).ChartObjects strOut = strOut & chr.Name & vbNewLine Next If Len(strOut) > 0 Then MsgBox "Chart Names are:" & vbNewLine & strOut Else MsgBox "No charts", vbCritical End If End Sub
The macro below outputs more information about the charts in a workbook and a worksheet than brettdj’s. The idea is to give you a fuller indication of the information that is available and how you access it.
However, I do not understand what you want to appear in the Name Box.
Sub Test1() Dim InxCO As Integer Dim InxWS As Integer For InxWS = 1 To Worksheets.Count With Sheets(InxWS) Debug.Print "Worksheet: " & .Name Debug.Print " " & .ChartObjects.Count & " charts" For InxCO = 1 To .ChartObjects.Count With .ChartObjects(InxCO) Debug.Print " Chart: " & .Name Debug.Print " Location: " & .TopLeftCell.Address & " to " & _ .BottomRightCell.Address If .Chart.HasTitle Then Debug.Print " Title: " & .Chart.ChartTitle.Text Else Debug.Print " Untitled" End If End With Next End With Next End Sub
If you have Excel 2007+, there is a Selection and Visibility window that you can activate.
To see this,
1) insert ANY shape on your sheet 2) **Format > Arrange > Selection Pane**
You can, at this point, right-click the Selection Pane icon and add it to your QAT. Using the icon on your QAT, means that the Selection and Visibility window can be activated any time, with or without shapes on a sheet.