Looping through selected charts

K

Keith B

I have a worksheet with a number of embedded charts. In previous versions of
Excel within a macro I could loop through the charts that the user has
selected (either one or more) by using code of the form:

If (ActiveChart Is Nothing) Then
For Each coChartObject In Selection
coChartObject.Chart.HasTitle = True
coChartObject.Chart.ChartTitle.Text = sInputBoxResponse
Next coChartObject
Else
ActiveChart.HasTitle = True
ActiveChart.ChartTitle.Text = sInputBoxResponse
End If

This code no longer works in 2007. What am I doing wrong? What code in
2007 can perform similarly?

Note: If I select one chart the object type of the selection is ChartArea,
if more than one chart is selected the object type of the selection is
ChartObjects. In the case of the latter, the .Count of the ChartObjects is
NOT equal to the number of charts that are selected, however, is equal to the
number of charts in the worksheet.

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top