PDA

Click to See Complete Forum and Search --> : Excel: Type Mismatch error in VBA


vonoventwin
Dec 22nd, 2005, 06:45 AM
Getting a Type Mismatch error on the line in Red, any ideas why? But if I take out the * 1.4503 it will take the value from Cell (0, 5) and put it in Cell (0, 9)


Sub Macro3()
Dim MyCell3 As Range

For Each MyCell3 In Sheet1.Columns("D").Cells
With MyCell3
If .Value = "" Then Exit For
If .Value <> "OMI" Then
.Offset(0, 9).Value = .Offset(0, 5).Value * 1.4503
Else
.Offset(0, 9).Value = .Offset(0, 5).Value
End If
End With
Next MyCell3

End Sub

si_the_geek
Dec 22nd, 2005, 12:28 PM
I guess that Value is a string then, in which case you can use code like this:

.Offset(0, 9).Value = CStr(CSng(.Offset(0, 5).Value) * 1.4503)