LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default type mismatch error when passing collection byRef

I have two possible collections that I might want a particular sub to operate
on. Both are Dim'd at the top of the module:
Dim my_AEs, my_AMs As Collection

....

the sub in question is:

Sub identify_team(ByVal team_name As String, ByRef col As Collection)

Dim last_row As Integer
Dim team_range As Range
Dim myRow As Range

Set col = New Collection

last_row = Sheets("Sales Team Lookup").Range("A1").End(xlDown).Row
Sheets("Sales Team Lookup").Activate '**can't avoid this line
Set team_range = Sheets("Sales Team Lookup").Range(("A1:E1"),
Range("A:E").Rows(last_row))

For Each myRow In team_range.Rows
If myRow.Cells(1, 2).Value = team_name And myRow.Cells(1, 4) = "AE"
Then
col.Add Item:=myRow.Cells(1, 1).Value, Key:=myRow.Cells(1,
1).Value
End If
Next myRow
End Sub

I call this by:

identify_team my_team_name, my_AEs

but this gives me a type mismatch error and highlights my_AEs.

The watch window says at this point that the Type of my_AEs is
Variant/Object/Collection.

I'd appreciate any advice or insights on this.

(I'd also really like to know why I need the line Sheets("Sales Team
Lookup").Activate in identify_team. If I leave this out it stops on the next
line. I can then click on the Sales Team Lookup sheet and click on continue
and it runs the rest of it fine. I don't understand why this is)

Many thanks in advance.

Tara H
 
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
HELP "ByRef Argument Type Mismatch" RocketMan[_2_] Excel Programming 6 June 7th 07 07:00 PM
passing range to function: type of argument is byref incompatible mcgurkle Excel Programming 3 May 7th 07 08:43 AM
Passing Userform Listbox to sub causes type-mismatch error Kleev Excel Programming 2 October 19th 05 08:46 PM
"ByRef argument type mismatch" Error Baapi[_4_] Excel Programming 2 September 17th 05 12:47 AM
ByRef argument type mismatch error? sermest Excel Programming 4 June 17th 05 06:50 PM


All times are GMT +1. The time now is 06:01 PM.

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"