VBA and charts
Hi all. I'm having trouble working with charts in Excel using Visual basic.
What I'm trying to do is take an embedded chart that is selected, copy and paste it, then select the original chart. The trouble I'm having is that I just can't get visual basic to tell me the index of the active chart! Msgbox ActiveChart.Index returns an "Method 'Index' of object '_Chart' failed" error Msgbox ActiveChart.name works, but returns "charts Chart 12" for example. This would be fine if I could then use this to refer to the chart later, but I think the extra "charts" is throwing it off Can anyone offer any help Eric |
VBA and charts
This gives the number for the chartObject --
Sub GetIndex() Dim chObj As ChartObject Set chObj = ActiveChart.Parent Debug.Print ActiveSheet _ .ChartObjects(chObj.Name).Index End Sub Eric wrote: Hi all. I'm having trouble working with charts in Excel using Visual basic. What I'm trying to do is take an embedded chart that is selected, copy and paste it, then select the original chart. The trouble I'm having is that I just can't get visual basic to tell me the index of the active chart! Msgbox ActiveChart.Index returns an "Method 'Index' of object '_Chart' failed" error. Msgbox ActiveChart.name works, but returns "charts Chart 12" for example. This would be fine if I could then use this to refer to the chart later, but I think the extra "charts" is throwing it off. Can anyone offer any help? Eric -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html |
All times are GMT +1. The time now is 06:44 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com