+ Reply to Thread
Results 1 to 3 of 3

Mismatch error

  1. #1
    Registered User
    Join Date
    06-06-2008
    Posts
    13

    Mismatch error

    The code below is supposed to search an array B in column A
    and highlight all the matches. I keep getting a mismatch error. Can someone help me? Thanks
    Sub FindAndHighlight()

    Dim FirstAddx As String
    Dim LastRow As Long
    Dim N As Long
    Dim R As Long
    Dim SrchRng As Range
    Dim SrchRslt As Range
    Dim SrchValue As Variant

    N = Cells(Rows.Count, "B").End(xlUp)
    For R = 1 To N
    SrchValue = Cells(R, "B")
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row

    Set SrchRng = Range("A1", Cells(LastRow, "A"))
    Set SrchRslt = SrchRng.Find(What:=SrchValue, _
    LookIn:=xlValues, _
    LookAt:=xlPart, _
    SearchORder:=xlRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)
    If Not SrchRslt Is Nothing Then
    FirstAddx = SrchRslt.Address
    Do
    SrchRslt.Interior.ColorIndex = 6
    Set SrchRslt = SrchRng.FindNext(SrchRslt)
    Loop While SrchRslt.Address <> FirstAddx And Not SrchRslt Is Nothing
    End If
    Next R

  2. #2
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi danielhliu,

    You need to change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    Hope this helps

    Seamus

  3. #3
    Registered User
    Join Date
    06-06-2008
    Posts
    13
    That did the trick. THANKS SO MUCH

+ 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