deselect any "active" charts in workbook

R

Raul

I have a number of worksheets with scrolling charts charts on them (one chart
per worksheeet) that are updated programmatically. The chart update routine
bombs when trying to modify a scrollbar property (.object.max) if a chart has
been selected (i.e., someone clicked on a chart).

I would like to add some code to my routine to deselect all active charts in
the workbook prior to updating the scrollbar property.

Can I deselect all active charts in a workbook? If so, how?

All help will be greatly appreciated.

Thanks in advance,
Raul

Thanks,
Raul
 
J

Jon Peltier

Loop through the worksheets, and select cell A1 on each.

For i = 1 To ActiveWorkbook.Worksheets.Count
With ActiveWorkbook.Worksheets(i)
.Activate
.Range("A1").Select
End With
Next

- Jon
 
R

Raul

Your solution worked like a charm.

I added an If statement to only activate worksheets with names that contain
a desired string.

For i = 1 To ActiveWorkbook.Worksheets.Count
If InStr(1, ActiveWorkbook.Worksheets(i).Name, "Scrlng", 1) <> 0 Then
With ActiveWorkbook.Worksheets(i)
.Activate
.Range("A1").Select
End With
End If
Next

Thanks,
Raul

By the way, are there any advantages or disadvantages to using a for each
loop?
 

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