Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Chart sheet causing error

Hi all,

I'm having a problem at the last line of this code:

For Each ws In Workbooks(sFile).Sheets
If ... Then
cboSheet.AddItem ws.Name
End If
Next

The problem occurs when I step into a chart sheet, which results in a type mismatch error. Why does that happen how do you handle that?

Gustaf
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Chart sheet causing error

You probably have ws defined as a variable of type worksheet. Either change
it to Object, or outsort the charts n the code.

HTH

Bob

"Gustaf" wrote in message
...
Hi all,

I'm having a problem at the last line of this code:

For Each ws In Workbooks(sFile).Sheets
If ... Then
cboSheet.AddItem ws.Name
End If
Next

The problem occurs when I step into a chart sheet, which results in a type
mismatch error. Why does that happen how do you handle that?

Gustaf



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Chart sheet causing error

You're right. The ws variable is indeed defined as Worksheet. It's preferred, because that's how it's done in the rest of the project. However, I don't think outsorting the charts would work, because the error occurs already on the "Next" line, before returning to the top of the loop.

Gustaf

Bob Phillips wrote:
You probably have ws defined as a variable of type worksheet. Either change
it to Object, or outsort the charts n the code.

HTH

Bob

"Gustaf" wrote in message
...
Hi all,

I'm having a problem at the last line of this code:

For Each ws In Workbooks(sFile).Sheets
If ... Then
cboSheet.AddItem ws.Name
End If
Next

The problem occurs when I step into a chart sheet, which results in a type
mismatch error. Why does that happen how do you handle that?

Gustaf



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Chart sheet causing error

If you keep it as type worksheet, you HAVE to outsort the charts, otherwise
it will just fail as you have found.

HTH

Bob

"Gustaf" wrote in message
...
You're right. The ws variable is indeed defined as Worksheet. It's
preferred, because that's how it's done in the rest of the project.
However, I don't think outsorting the charts would work, because the error
occurs already on the "Next" line, before returning to the top of the
loop.

Gustaf

Bob Phillips wrote:
You probably have ws defined as a variable of type worksheet. Either
change it to Object, or outsort the charts n the code.

HTH

Bob

"Gustaf" wrote in message
...
Hi all,

I'm having a problem at the last line of this code:

For Each ws In Workbooks(sFile).Sheets
If ... Then
cboSheet.AddItem ws.Name
End If
Next

The problem occurs when I step into a chart sheet, which results in a
type mismatch error. Why does that happen how do you handle that?

Gustaf



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 834
Default Chart sheet causing error

It is easily outsorted like so

Dim ws As Worksheet
For Each ws In Workbooks(sFile).Worksheets
If ... Then
cboSheet.AddItem ws.Name
End If
Next

HTH

Bob

"Gustaf" wrote in message
...
You're right. The ws variable is indeed defined as Worksheet. It's
preferred, because that's how it's done in the rest of the project.
However, I don't think outsorting the charts would work, because the error
occurs already on the "Next" line, before returning to the top of the
loop.

Gustaf

Bob Phillips wrote:
You probably have ws defined as a variable of type worksheet. Either
change it to Object, or outsort the charts n the code.

HTH

Bob

"Gustaf" wrote in message
...
Hi all,

I'm having a problem at the last line of this code:

For Each ws In Workbooks(sFile).Sheets
If ... Then
cboSheet.AddItem ws.Name
End If
Next

The problem occurs when I step into a chart sheet, which results in a
type mismatch error. Why does that happen how do you handle that?

Gustaf





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Chart sheet causing error

Thank you very much! :-)

Gustaf

--
Bob Phillips wrote:
It is easily outsorted like so

Dim ws As Worksheet
For Each ws In Workbooks(sFile).Worksheets
If ... Then
cboSheet.AddItem ws.Name
End If
Next

HTH

Bob

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copied sheet causing duplicate range name error (Excel 2010) jgeniti Excel Discussion (Misc queries) 0 November 17th 11 04:55 PM
What's causing error message? Jim Tibbetts Excel Worksheet Functions 4 November 12th 08 06:13 PM
What's causing error message? Jim Tibbetts Excel Programming 1 November 12th 08 05:55 PM
Query causing #ref error in spreadsheet endro Excel Discussion (Misc queries) 0 May 14th 08 12:03 AM
INSERT INTO sql statement causing error Michael Malinsky[_2_] Excel Programming 1 September 21st 05 08:07 PM


All times are GMT +1. The time now is 08:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"