+ Reply to Thread
Results 1 to 3 of 3

"If" statement results in Type mismatch error.

  1. #1
    Registered User
    Join Date
    10-28-2011
    Location
    Lehigh Valley, PA
    MS-Off Ver
    Excel 2007
    Posts
    18

    "If" statement results in Type mismatch error.

    Hi,

    The "If" statement below results in a
    Run Time Error 13
    Type Mismatch

    What would be the correct way to construct the "If" statement?

    Thanks


    Sub MakeSimilarDist()
    '
    last = Cells(Rows.Count, "AM").End(xlUp).Row
    For i = last To 1 Step -1
    If (Cells(i, "AM").Value) < (Cells(i, "DS").Value) + 0.6 Or (Cells(i, "AM").Value) > (Cells(i, "DS").Value) - 0.6 Then
    Cells(i, "A").EntireRow.Delete
    End If
    Next i
    '
    End Sub
    Last edited by msmick; 11-13-2012 at 12:26 AM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: "If" statement results in Type mismatch error.

    Try:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: "If" statement results in Type mismatch error.

    msmick...

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1