Results 1 to 4 of 4

Error 13 when searching for string matching range values

Threaded View

  1. #1
    Valued Forum Contributor
    Join Date
    01-16-2012
    Location
    England
    MS-Off Ver
    MS 365 Version 2501 64-bit
    Posts
    1,465

    Error 13 when searching for string matching range values

    Col A of Sheet 2 has a series of "keywords"

    Col B on sheet 1 has a list of products.

    Macro should "cycle" through each product to find matches with any keyword.

    If a match is found. the keyword should be added to Col C of the row

    If no match is found, Col C of the row becomes "Other"

    Code is throwing an Error 13 "Type Mismatch"

    Option Explicit
    
    Sub findmatch()
    
    Dim b As Long, d As Long, x As Long
    
    'Find last row of data
    
        With Sheet1
        b = .Cells(.Rows.Count, "B").End(xlUp).Row
        End With
    
        For x = 2 To b
        For d = 2 To 6
     
    'Checks whether B* contains the first keyword in Sheet 2
    
        If InStr(Range("B" & x).Value, Sheet2.Range("a" & d), vbTextCompare) <> 0 Then 
        Range("C" & x) = Sheet2.Range("a" & d)
        End If
    
        Next
    
    'If none of the keywords match, put "Other" in Col C
        Range("C" & x) = "Other"
    
    'Repeat for next row
    
        Next
    
    End Sub
    Suggestions and pointers welcome as ever

    Ochimus
    Attached Files Attached Files
    Last edited by Ochimus; 03-07-2016 at 10:45 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Having trouble searching for and matching 2 values
    By PaulMcCudden in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 06-25-2015, 05:54 PM
  2. [SOLVED] Searching for unknown text string in a range and then matching it to a reference table
    By the_nibs in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 06-10-2015, 07:26 AM
  3. Searching for user defined value in range, sending only these values to array ERROR
    By sgonzalez90 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2013, 01:02 AM
  4. Searching for multiple matching column values
    By watppuiu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-05-2012, 12:19 AM
  5. Searching for values within a string across a range of cells
    By futureboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2010, 07:53 PM
  6. Searching a String for a Matching Word from another String
    By ExcelTip in forum Tips and Tutorials
    Replies: 0
    Last Post: 08-23-2005, 04:01 AM
  7. Replies: 1
    Last Post: 01-07-2005, 01:06 PM

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