Why am I getting a "Type mismatch" Error

  • Thread starter Thread starter Mac Lingo
  • Start date Start date
M

Mac Lingo

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top