Results 1 to 3 of 3

type mismatch error in code

Threaded View

  1. #1
    Registered User
    Join Date
    08-06-2008
    Location
    Los Angeles
    Posts
    10

    type mismatch error in code

    I gave this coding thing a stab and came up with this code

    Sub promo()
    Dim LastRow As Long, i As Long, ii As Long
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    
    For i = LastRow To 2 Step -1
     If Cells(i, "E").Value = "A" And Cells(i, "L").Value = "Incorrect creative/correct car" And Cells(i, "A").Value = "B" Then
        Cells(i, "N") = "C" And Cells(i, "M") = "D"
     End If
    unfortunately, I get an error "type mismatch" and choosing the debug option directs me to this line:

    Cells(i, "N") = "C" And Cells(i, "M") = "D"
    Oh, with the help of a friend I figured out what happened:

    "and" generally can't be placed in anything within a "then" statement. Instead I should've followed this syntax:

    Cells(i, "N") = "C"
    Cells(i, "M") = "D"
    mods: feel free to delete this if this knowledge is too basic. I don't know a lick of this coding business and made an easy goof. Thanks.
    Last edited by strikeofdawn; 08-08-2008 at 08:32 PM.

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