Finding type of worksheet using VBA

  • Thread starter Arturs Jurnieks
  • Start date
A

Arturs Jurnieks

Hi,
I'm trying to figure out a way to identify the type of worksheets in
an Excel workbook using VBA, but I'm getting a runtime error "438"
message.

Basically I need to know if a worksheet sheet(i) is a Chart sheet or
normal worksheet. Could someone give me some advice on how to do this?
Thanks!

My code looks something like this:

If Sheets(i).XlSheetType = xlWorksheet Then
' do something
elseif Sheets(i).XlSheetType = xlChart Then
' do something else
Endif

Appreciate any help on this.

Arturs
 
J

jaf

Hi Arturs,
Thats to easy. ;<)

sub testworks()
dim ws as object
for each ws in sheets
if typeof ws is chart then debug.print ws.name & " is a chart"
if typeof ws is worksheet then debug.print ws.name & " is a worksheet"
next
end sub



--
John
johnf 202 at hotmail dot com


| Hi,
| I'm trying to figure out a way to identify the type of worksheets in
| an Excel workbook using VBA, but I'm getting a runtime error "438"
| message.
|
| Basically I need to know if a worksheet sheet(i) is a Chart sheet or
| normal worksheet. Could someone give me some advice on how to do this?
| Thanks!
|
| My code looks something like this:
|
| If Sheets(i).XlSheetType = xlWorksheet Then
| ' do something
| elseif Sheets(i).XlSheetType = xlChart Then
| ' do something else
| Endif
|
| Appreciate any help on this.
|
| Arturs
 

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