I need to modify selected charts when more than one chart is selected. Imagine that you have three charts and you select the 3rd and the 2nd. How can I find out which charts are selected?
I tried Application.Selection.Item(idx).Chart but when idx=1 it does not return 1st selected chart (3rd chart) but 1st chart which is not selected. Strange thing is that in Watches window the item Application.Selection.Item(1) shows 1st selected chart (3rd chart) but in macro it returns 1st chart not 1st selected chart (3rd chart).
Try to create three charts select the 3rd and the 2nd and trace this code:
The problem is that Application.Selection.Item(idx) does not return selected charts but two 1st charts. Value Application.Selection.Count is correct.Sub TestSel() 'Select Chart 3 and Chart 2 using Ctrl key Dim chrt(10) As String For idx = 1 To Application.Selection.Count chrt(idx) = Application.Selection.Item(idx).Name Next idx 'Now see what is stored in chrt(1) and chrt(2) For idx = 1 To Application.Selection.Count MsgBox (chrt(idx)) 'Result should be Chart 3 and Chart 1 but it returns Chart 1 and Chart 2 Next idx End Sub
Any solution?
This will return the selected chart names
For idx = 1 To Application.Selection.Count chrt(idx) = Application.Selection.ShapeRange.Item(idx).Name Next idx
Thank you. Works great!
And this is how to work with Charts:
Application.Selection.ShapeRange.Item(idx).Chart
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks