Monday, May 23, 2005

Loop Through Charts in Excel Worksheet

Here’s a quick piece of code that will generate message boxes for every chart in the active worksheet with the name and top position of the chart

Sub LoopThruCharts()

For i = 1 To ActiveSheet.ChartObjects.Count
ActiveSheet.ChartObjects(i).Select
MsgBox ActiveSheet.ChartObjects(i).Name
MsgBox ActiveChart.Parent.Top
Next i

End Sub

1 comment:

Jon said...

Fantastic yet simple piece of code. A variation of it allows me to go through a sheet I have with 50 charts and perform what has to this point been a manual and time consuming process. THANKS!