Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Mismatch Error

I'm getting a type mismatch error on the following section of code - any ideas?

========
Set wsDest = Workbooks("NI Insurer Market Share as at " & Format(Date,
"yyyy-mmmm") & ".xls").Worksheets(Array("PC (Chart)-NI-MONTH", _
"PC (Chart)-NI-YTD", "PC (Chart)-NI-R12", "HH (Chart)-NI-MONTH", _
"HH (Chart)-NI-YTD", "HH (Chart)-NI-R12", "CV (Chart)-NI-MONTH", _
"CV (Chart)-NI-YTD", "CV (Chart)-NI-R12"))
========

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Mismatch Error

I don't believe that you can set your wsDest variable (which I assume is
declared As Worksheet) to an array of multiple worksheets. You can assign
only a single worksheet object to a Worksheet typed object variable.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)




"Sarah (OGI)" wrote in message
...
I'm getting a type mismatch error on the following section of code - any
ideas?

========
Set wsDest = Workbooks("NI Insurer Market Share as at " & Format(Date,
"yyyy-mmmm") & ".xls").Worksheets(Array("PC (Chart)-NI-MONTH", _
"PC (Chart)-NI-YTD", "PC (Chart)-NI-R12", "HH (Chart)-NI-MONTH", _
"HH (Chart)-NI-YTD", "HH (Chart)-NI-R12", "CV (Chart)-NI-MONTH", _
"CV (Chart)-NI-YTD", "CV (Chart)-NI-R12"))
========

Thanks in advance


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Mismatch Error

Hi Sarah.

Perhaps you have dimmed the variable
wsDest as Worksheets? Note that a
Chart is included in the Sheets collection;
it is not a worksheet and, therefore is not
included in the Worksheets collection.

Try:

Dim wsDest as Sheets


Additionally, try changing:

Worksheets(Array....

to

Sheets(Array


---
Regards.
Norman


"Sarah (OGI)" wrote in message
...
I'm getting a type mismatch error on the following section of code - any
ideas?

========
Set wsDest = Workbooks("NI Insurer Market Share as at " & Format(Date,
"yyyy-mmmm") & ".xls").Worksheets(Array("PC (Chart)-NI-MONTH", _
"PC (Chart)-NI-YTD", "PC (Chart)-NI-R12", "HH (Chart)-NI-MONTH", _
"HH (Chart)-NI-YTD", "HH (Chart)-NI-R12", "CV (Chart)-NI-MONTH", _
"CV (Chart)-NI-YTD", "CV (Chart)-NI-R12"))
========

Thanks in advance


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Mismatch Error

Hi Sarah,

Try:


Dim wsDest as Sheets


Or, if all the sheets of interest are charts:


Dim wsDest as Charts



---
Regards.
Norman
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Mismatch Error

Dim wsDest as Sheets

I don't think that will solve anything.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Norman Jones" wrote in message
...
Hi Sarah.

Perhaps you have dimmed the variable
wsDest as Worksheets? Note that a
Chart is included in the Sheets collection;
it is not a worksheet and, therefore is not
included in the Worksheets collection.

Try:

Dim wsDest as Sheets


Additionally, try changing:

Worksheets(Array....

to

Sheets(Array


---
Regards.
Norman


"Sarah (OGI)" wrote in message
...
I'm getting a type mismatch error on the following section of code - any
ideas?

========
Set wsDest = Workbooks("NI Insurer Market Share as at " & Format(Date,
"yyyy-mmmm") & ".xls").Worksheets(Array("PC (Chart)-NI-MONTH", _
"PC (Chart)-NI-YTD", "PC (Chart)-NI-R12", "HH (Chart)-NI-MONTH", _
"HH (Chart)-NI-YTD", "HH (Chart)-NI-R12", "CV (Chart)-NI-MONTH", _
"CV (Chart)-NI-YTD", "CV (Chart)-NI-R12"))
========

Thanks in advance





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default Mismatch Error

Hi Chip,

============
Dim wsDest as Sheets


I don't think that will solve anything.
============

The following appeared to work for me:

'==========
Public Sub Tester()
Dim wsDest As Sheets
Dim i As Long
Dim sStr As String

sStr = "NI Insurer Market Share as at " _
& Format(Date, "yyyy-mmmm")

Set wsDest = Workbooks(sStr).Sheets(Array( _
"PC (Chart)-NI-MONTH", _
"PC (Chart)-NI-YTD", _
"PC (Chart)-NI-R12", _
"HH (Chart)-NI-MONTH", _
"HH (Chart)-NI-YTD", _
"HH (Chart)-NI-R12", _
"CV (Chart)-NI-MONTH", _
"CV (Chart)-NI-YTD", _
"CV (Chart)-NI-R12"))

For i = 1 To wsDest.Count
Debug.Print wsDest(i).Name & vbTab _
& TypeName(wsDest(i))
Next i
End Sub
'<<=========


---
Regards.
Norman
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Mismatch Error

I tried the same thing and got a error. Go figure.


--
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



"Norman Jones" wrote in message
...
Hi Chip,

============
Dim wsDest as Sheets


I don't think that will solve anything.
============

The following appeared to work for me:

'==========
Public Sub Tester()
Dim wsDest As Sheets
Dim i As Long
Dim sStr As String

sStr = "NI Insurer Market Share as at " _
& Format(Date, "yyyy-mmmm")

Set wsDest = Workbooks(sStr).Sheets(Array( _
"PC (Chart)-NI-MONTH", _
"PC (Chart)-NI-YTD", _
"PC (Chart)-NI-R12", _
"HH (Chart)-NI-MONTH", _
"HH (Chart)-NI-YTD", _
"HH (Chart)-NI-R12", _
"CV (Chart)-NI-MONTH", _
"CV (Chart)-NI-YTD", _
"CV (Chart)-NI-R12"))

For i = 1 To wsDest.Count
Debug.Print wsDest(i).Name & vbTab _
& TypeName(wsDest(i))
Next i
End Sub
'<<=========


---
Regards.
Norman


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
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
runtime error 13 - type mismatch error in Excel 97 on Citrix Kevin Maher Excel Programming 7 March 8th 08 11:48 AM
xpath error? Runtime Error 13 type mismatch SteveM Excel Discussion (Misc queries) 1 December 4th 07 09:16 AM
Conditional Formatting - Run Time Error '13' Type Mismatch Error ksp Excel Programming 0 July 11th 06 07:06 AM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


All times are GMT +1. The time now is 10:19 AM.

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

About Us

"It's about Microsoft Excel"