Chart vs Sheet distinction

  • Thread starter Thread starter Filo
  • Start date Start date
F

Filo

Hello-

I would like a program to run only if the activeworksheet is not a
chartsheet. Can you please help? I basically need something like:

If activeworksheet is a chart then
exit sub
else
....code...
end if


Thank you!
 
One way...

Dim wks As Worksheet

On Error Resume Next
Set wks = ActiveSheet
On Error GoTo 0

If wks Is Nothing Then
MsgBox "ChartSheet"
End If
 
Or...

If Typename(ActiveSheet) = "Worksheet" Then
' do your stuff
End If

- Jon
 
or

Function IsActiveSheetChart() As Boolean
Dim c As Chart

On Error Resume Next
Set c = ActiveWorkbook.Charts(ActiveSheet.Name)
If Err = 0 Then
IsActiveSheetChart = True
Else
IsActiveSheetChart = False
End If
On Error GoTo 0
Set c = Nothing
End Function
 

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

Back
Top