For no cause? Object Type Mismatch Error

blairintern

New Member
Joined
Jul 16, 2007
Messages
21
I am receiving a "Object Type Mismatch Error" with my variable CallPrice, an element of the user-defined class IssueClass.

Do
With Sheets("Input").Range("A1")
If .Offset(i, 0) Is Nothing Then
i = i + 1
Else
Set Bonds = New IssueClass
Bonds.Purpose = .Offset(i, 2) & " " & .Offset(i, 4) _
& " " & .Offset(i, 5)
Bonds.DatedDate = .Offset(i, 0)
Bonds.Series = .Offset(i, 3)
Bonds.Par = .Offset(i, 7)
Bonds.CallDate = .Offset(i, 8)
Bonds.CallPrice = .Offset(i, 9) HERE
Bonds.Fitch = .Offset(i, 10)
Bonds.Moody = .Offset(i, 11)
Bonds.SandP = .Offset(i, 12)
Bonds.Underwriter = .Offset(i, 16)
Bonds.Counsel = .Offset(i, 17)
' Bonds.Refunded = .Offset(i, 19)
' Bonds.Insurance = .Offset(i, 26) ' not yet on form
Set AllIssues(n) = Bonds
n = n + 1
i = i + 1
End If
End With
Loop Until ActiveCell.Range("A1").Offset(i, 0).Value = "Session Det"

The CallPrice code is as follows:
Private pCallDate As String
Private pCallPrice As Integer
Private pCallInfo As String

Property Let CallDate(D As String)
pCallDate = D
End Property
Property Let CallPrice(p As Integer)
If p <> "" Then
pCallPrice = p
End If
End Property
Sub CreateCall()
pCallDate = Format("mm/dd/yy")
pCallInfo = pCallDate & " @ " & pCallPrice
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
What's actually in the cell?

By the way why are you using such a complicated method?
 
Upvote 0
I'm not too sure how to make the method less complicated. I've never been a very succinct programmer... :/

The end result is a format-heavy worksheet displaying all of this information. If you think there's a better way to troll through the input i'd certainly'd be intrigued.

The input cell itself, at least in the first iteration is nothing. Not until about 3 rows down is it populated with the number 102.00.

--If i can toss another question on there, what if there's an error in the input (i.e. 102.00# instead of 102.00--is there any way to parse that down so it becomes a integer?)

Thanks!
 
Upvote 0
Well 102.00 might not be regarded as an integer by VBA even though the decimal part is .00.

There are various ways to convert values eg Int, Cint.

As to if I think there's a better way, that's hard to tell because I don't actually know what you are doing - all I've seen so far is your code.

And it seems that you might be overcomplicating things.

I don't see why you are using classes.:)
 
Upvote 0
From what i have read in the last week or so, it made sense. I have a bit of java background and that relies on classes pretty heavily. So I suppose that's my logic. I have no doubt that this is over-complicated. I was never a winner at the least-lines of code assignments in school.

Thanks for your leads. I will investigate CINT and INT to see what type of damage i can do with those.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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