View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Checking if a Chart Exists on a Sheet

Sub test()
Dim i As Long
Dim s As String
Dim ws As Worksheet

Set ws = ActiveSheet

For i = 1 To ws.ChartObjects.Count
s = s & ws.ChartObjects(i).Name & vbCr
Next

If Len(s) = 0 Then s = "No Charts on " & ws.Name

MsgBox s
End Sub

Regards,
Peter T


"Keith Wilby" wrote in message
...
"Keith Wilby" wrote in message
...
Newbie question:

What code do I need to check if a chart exists on a worksheet?


Whoops, how do I determine it's name if one exists? I've tried
ActiveSheet.ChartObjects.ActiveChart.Name but that's obviously not right.