+ Reply to Thread
Results 1 to 9 of 9

Searching through worksheet for a list of items

  1. #1
    Registered User
    Join Date
    01-28-2014
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Searching through worksheet for a list of items

    I am trying to find all customers who have a certain code associated with them.

    One worksheet has a list of the customers, with separate columns for each code associated with them.
    The second worksheet has a list of codes I'm looking for.

    I found code on this forum that I can use to search, but it only searches through one specified column.

    I've been trying to get this code to loop through all columns on the spreadsheet, but I'm getting it all twisted and tangled.

    In addition, is there a way to use wildcards in the way this search is set up?
    For instance, any codes that fall between S00 and S99 are valid.

    I've attached a spreadsheet. Thanks for your help.
    Attached Files Attached Files
    Last edited by Brandon2013; 06-13-2019 at 12:16 PM.

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Searching through worksheet for a list of items

    How would you like to display the result ???
    - Battle without fear gives no glory - Just try

  3. #3
    Registered User
    Join Date
    01-28-2014
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Searching through worksheet for a list of items

    It would work to simply write "Match" in column B if the row contains any of the items in the search list.

    Thanks

  4. #4
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Searching through worksheet for a list of items

    See next code and file attached for the display
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-28-2014
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Searching through worksheet for a list of items

    Thank you. This worked great on my sample file. I'll play around with it tonight on my large file.

  6. #6
    Registered User
    Join Date
    01-28-2014
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Searching through worksheet for a list of items

    I am getting an error if one of the Visit Rows does not have a matching item in the Codes sheet.

    I have tried different ways of checking to see if NameDic.Items(K).Keys has values, but I cannot find the proper syntax.
    Please Login or Register  to view this content.
    Would that be the best way to deal with rows that don't have a match?

    Thanks

  7. #7
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: Searching through worksheet for a list of items

    See next corrective code

    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this ‼


    Quote Originally Posted by Brandon2013 View Post
    It would work to simply write "Match" in column B if the row contains any of the items in the search list.
    According to your attachment a demonstration as a beginner starter :

    PHP Code: 
    Sub Demo()
         
    Dim V2M$(), V1R&, C%, S$()
             
    V2 Sheet2.Range("A2"Sheet2.[A1].End(xlDown)).Value2
        With Sheet1
    .UsedRange.Rows("2:" Sheet1.UsedRange.Rows.Count).Columns
                ReDim M
    (1 To .Rows.Count0)
                
    V1 = .Item(3).Resize(, .Count 2).Value2
            
    For 1 To UBound(V1)
                For 
    1 To UBound(V12)
                    If 
    IsEmpty(V1(RC)) Then Exit For
                    
    Split(LTrim(V1(RC)))
                    If 
    S(0Like "S##" Or IsNumeric(Application.Match(S(0), V20)) Then M(R0) = "Match": Exit For
                
    Next
            Next
                
    .Item(2).Value2 M
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  9. #9
    Registered User
    Join Date
    01-28-2014
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Searching through worksheet for a list of items

    Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Issue searching for text within a list on one Worksheet from cell values in another
    By jsturbo in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-21-2017, 02:21 PM
  2. [SOLVED] Creating a grocery list in a new worksheet based on selected items in a master list
    By jacolli4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-28-2012, 07:53 AM
  3. Replies: 4
    Last Post: 07-26-2012, 11:31 AM
  4. Replies: 3
    Last Post: 06-27-2012, 02:38 PM
  5. Compare 2 Worksheet and List All Items that Matched
    By Vinnie Chan in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-13-2010, 02:09 PM
  6. Show List of items from cells in one worksheet in another worksheet
    By robrussell in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-24-2010, 07:29 AM
  7. Selecting items from a list. To transfer to another worksheet?
    By Mountain goat in forum Excel General
    Replies: 0
    Last Post: 09-19-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