Hi guys, I'm trying to call the function "mduration" in VBA. It outputs the correct numbers but it always says: "type mismatch" after performing the calculations.
Here's the code:
Cell.Offset(0, 15).Formula = "=mduration(" & Chr(34) & Date & Chr(34) & ", " & Chr(34) & Cell.Offset(0, 6).Value & Chr(34) & ", " & Chr(34) & Cell.Offset(0, 4).Value / 100 & Chr(34) & ", " & Chr(34) & Cell.Offset(0, 14).Value / 100 & Chr(34) & ", " & Chr(34) & Cell.Offset(0, 5).Value & Chr(34) & ")"
Cell.offset(0,14).value refers to yield. It has the following code which works fine:
Cell.Offset(0, 14).Formula = "=yield(" & Chr(34) & Date & Chr(34) & ", " & Chr(34) & Cell.Offset(0, 6).Value & Chr(34) & ", " & Chr(34) & Cell.Offset(0, 4).Value / 100 & Chr(34) & ", " & Chr(34) & Cell.Offset(0, 12).Value & Chr(34) & "," & Chr(34) & 100 & Chr(34) & "," & Chr(34) & Cell.Offset(0, 5).Value & Chr(34) & ")*100"
Cell.Offset(0, 14).Value = Cell.Offset(0, 14).Value
Any suggestions as to how to combat the type mismatch error?
Bookmarks