Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default array - type mismatch

I have the following section of code which is giving me a "type
mismatch" error at:
== For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)

Can anyone help with this?
Thanks...


Dim CapsSheetarr As Variant
Dim CapsSheets As Integer
Dim tlcapscell As Range
Dim blcapscell As Range
Dim brcapscell As Range
Dim capsrange As Range

Set CapsSheetarr = Sheets(Array("Metro AHK Base", "Metro AHK
Complete"))
For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)
With Worksheets("" & CapsSheetarr(CapsSheets))
.Select
Set tlcapscell = .Cells(3, 2)
Set blcapscell = .Cells(Rows.Count,
tlcapscell.Column).End(xlUp)
Set brcapscell = .Cells(blcapscell.Row,
blcapscell.Column).End(xlToRight)
Set capsrange = Range(tlcapscell, brcapscell)
End With
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default array - type mismatch

Hi
Take away the Sheets bit and leave
Array("Metro AHK Base", "Metro AHK Complete")

regards
Paul
On Mar 12, 7:42*pm, Steve wrote:
I have the following section of code which is giving me a "type
mismatch" error at:
== For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)

Can anyone help with this?
Thanks...

* * Dim CapsSheetarr As Variant
* * Dim CapsSheets As Integer
* * Dim tlcapscell As Range
* * Dim blcapscell As Range
* * Dim brcapscell As Range
* * Dim capsrange As Range

* * Set CapsSheetarr = Sheets(Array("Metro AHK Base", "Metro AHK
Complete"))
* * * * For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)
* * * * * * With Worksheets("" & CapsSheetarr(CapsSheets))
* * * * * * * * .Select
* * * * * * * * Set tlcapscell = .Cells(3, 2)
* * * * * * * * Set blcapscell = .Cells(Rows.Count,
tlcapscell.Column).End(xlUp)
* * * * * * * * Set brcapscell = .Cells(blcapscell.Row,
blcapscell.Column).End(xlToRight)
* * * * * * * * Set capsrange = Range(tlcapscell, brcapscell)
* * * * * * End With
* * * * Next


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default array - type mismatch

Set CapsSheetarr = Array("Metro AHK Base", "Metro AHK Complete"))
For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)
With Worksheets(CapsSheetarr(CapsSheets))
.Select
Set tlcapscell = .Cells(3, 2)
Set blcapscell = .Cells(.Rows.Count, tlcapscell.Column).End(xlUp)
Set brcapscell _
= .Cells(blcapscell.Row, blcapscell.Column).End(xlToRight)
Set capsrange = .Range(tlcapscell, brcapscell)
End With
Next CapsSheets



Steve wrote:

I have the following section of code which is giving me a "type
mismatch" error at:
== For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)

Can anyone help with this?
Thanks...

Dim CapsSheetarr As Variant
Dim CapsSheets As Integer
Dim tlcapscell As Range
Dim blcapscell As Range
Dim brcapscell As Range
Dim capsrange As Range

Set CapsSheetarr = Sheets(Array("Metro AHK Base", "Metro AHK
Complete"))
For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)
With Worksheets("" & CapsSheetarr(CapsSheets))
.Select
Set tlcapscell = .Cells(3, 2)
Set blcapscell = .Cells(Rows.Count,
tlcapscell.Column).End(xlUp)
Set brcapscell = .Cells(blcapscell.Row,
blcapscell.Column).End(xlToRight)
Set capsrange = Range(tlcapscell, brcapscell)
End With
Next


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default array - type mismatch

Steve,

Set up your array like this

CapsSheetarr = Array("Metro AHK Base", "Metro AHKComplete")

instead of

Set CapsSheetarr = Sheets(Array("Metro AHK Base", "Metro AHK Complete"))

Mike


"Steve" wrote:

I have the following section of code which is giving me a "type
mismatch" error at:
== For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)

Can anyone help with this?
Thanks...


Dim CapsSheetarr As Variant
Dim CapsSheets As Integer
Dim tlcapscell As Range
Dim blcapscell As Range
Dim brcapscell As Range
Dim capsrange As Range

Set CapsSheetarr = Sheets(Array("Metro AHK Base", "Metro AHK
Complete"))
For CapsSheets = LBound(CapsSheetarr) To UBound(CapsSheetarr)
With Worksheets("" & CapsSheetarr(CapsSheets))
.Select
Set tlcapscell = .Cells(3, 2)
Set blcapscell = .Cells(Rows.Count,
tlcapscell.Column).End(xlUp)
Set brcapscell = .Cells(blcapscell.Row,
blcapscell.Column).End(xlToRight)
Set capsrange = Range(tlcapscell, brcapscell)
End With
Next

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
Type Mismatch: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
Type mismatch problem in array - ?? ina Excel Programming 6 May 17th 06 12:56 PM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM


All times are GMT +1. The time now is 05:13 AM.

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"