Results 1 to 2 of 2

Thread: Excel: Type Mismatch error in VBA

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Excel: Type Mismatch error in VBA

    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)

    VB Code:
    1. Sub Macro3()
    2. Dim MyCell3 As Range
    3.  
    4. For Each MyCell3 In Sheet1.Columns("D").Cells
    5. With MyCell3
    6.     If .Value = "" Then Exit For
    7.     If .Value <> "OMI" Then
    8.         [COLOR=Red].Offset(0, 9).Value = .Offset(0, 5).Value * 1.4503[/COLOR]
    9.     Else
    10.         .Offset(0, 9).Value = .Offset(0, 5).Value
    11.     End If
    12. End With
    13. Next MyCell3
    14.  
    15. End Sub

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Excel: Type Mismatch error in VBA

    I guess that Value is a string then, in which case you can use code like this:
    VB Code:
    1. .Offset(0, 9).Value = CStr(CSng(.Offset(0, 5).Value) * 1.4503)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width