Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Why am I getting a "Type mismatch" Error

I have the following code in my VBA Program

Public Col_Ptrs(3) As Integer

and later in the program in a Macro is a call to "Columns3"

Call Columns3(Col_Ptrs).

The Function "Columns3" is specified as follows:

Sub Columns3(Cols())

And I get an Compile Error messages as follows:
Type Mismatch: Array or User Defined Type expected.

I have mocked it up in a little subroutine and it works there. But it
doesn't here. Why?

Thanks,
Mac Lingo
Berkeley, CA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Why am I getting a "Type mismatch" Error

If you don't declare the data type of a variable then it is assigned a
datatype of Variant. So in Sub Columns3(Cols()) your argument is a
Variant array but you are passing it an Integer array. So you can fix it
by using:
Sub Columns3(Cols() as Integer)

Hope this helps
Rowan

Mac Lingo wrote:
I have the following code in my VBA Program

Public Col_Ptrs(3) As Integer

and later in the program in a Macro is a call to "Columns3"

Call Columns3(Col_Ptrs).

The Function "Columns3" is specified as follows:

Sub Columns3(Cols())

And I get an Compile Error messages as follows:
Type Mismatch: Array or User Defined Type expected.

I have mocked it up in a little subroutine and it works there. But it
doesn't here. Why?

Thanks,
Mac Lingo
Berkeley, CA


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
Error Handling to mitigate "Run Time Erorr 13 Type Mismatch" ExcelMonkey Excel Programming 3 October 16th 05 01:56 PM
"ByRef argument type mismatch" Error Baapi[_4_] Excel Programming 2 September 17th 05 12:47 AM
Run-time Error "13" - File Type Mismatch brentm Excel Programming 1 February 10th 05 05:09 PM
"FIND" generates "Type mismatch" error quartz[_2_] Excel Programming 5 November 16th 04 03:29 PM
Copying data to another worksheet gives "Type Mismatch" error TB[_3_] Excel Programming 6 July 28th 03 12:44 PM


All times are GMT +1. The time now is 10:09 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"