Excel 2007 Runtime Error 13 Type Mismatch

Rster0211

New Member
Joined
Apr 12, 2013
Messages
2
Please help, I'm stumped. I keep getting the type mismatch error at the following sections of code:

Code:
Public Function GetCurrentSk() As Integer
Dim meqptID As Integer
meqptID = 0
If cItems.ePrimary <> 0 Then '@runtime, cItems.ePrimary = 17
    meqptID = ListForm.GetNumReferenceUsed(cItems.ePrimary) '<- Type Mismatch upon execution at this line
End If
GetCurrentSk = meqptID
End Function

The follow is the code for ListForm.GetNumReferenceUsed:

Code:
Public Function GetNumReferenceUsed(ByVal eRow As Integer) As Integer
GetNumReferenceUsed = dRefUsed(eRow - 2) '<- debugger never reaches this function, type mismatch before here
End Function

Some background: cItems.ePrimary is a class with public property get which returns an integer (17) in this example.
dRefUsed() is an array of integers, in this example it has 18 items and I'm accessing the 15th.
ListForm is separate form with the public function GetNumReferenceUsed. ListForm is loaded at runtime.

I've been pulling data from the ListForm through other functions without an issue, and only this one seems to be a problem. Thanks in advance for the assistance!
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Immediately before the line meqptID = ListForm.GetNumReferenceUsed(cItems.ePrimary) insert a line which reads:-

Debug.Print cItems.ePrimary, ListForm.GetNumReferenceUsed(cItems.ePrimary)

When the program abends, look in the Immediate window (Ctrl-G) to see what value caused it. That might give you a clue.
 
Upvote 0
Immediately before the line meqptID = ListForm.GetNumReferenceUsed(cItems.ePrimary) insert a line which reads:-

Debug.Print cItems.ePrimary, ListForm.GetNumReferenceUsed(cItems.ePrimary)

When the program abends, look in the Immediate window (Ctrl-G) to see what value caused it. That might give you a clue.

I get the same error on the Debug line. Type mismatch. ePrimary is still reading the value of 17.

Debug.Print cItems.ePrimary succeeds
Debug.Print ListForm.GetNumReferenceUsed(17) fails as a type mismatch, even when i test a hard-coded value of 17.
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top