+ Reply to Thread
Results 1 to 6 of 6

Search Code vba return to the new sheet with duplicate data

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Search Code vba return to the new sheet with duplicate data

    Hello,

    I have a vba code to search and return data in the new sheet. However, if I search a specific word It will return double data since the item has two column has the same name.
    For example: I have an item
    Cust SKU Customer Desc Family Sub Family
    811724 Walmart Can REFLECTIVE PAW CAT Cat C&L Cat C&L

    So whenever I search the word Cat C&L it will result a duplicate value.


    Is there a way that when I search something it only return unique Customer SKU that locate in column G. Please see my code below


    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Search Code vba return to the new sheet with duplicate data

    Change this line
    With ws.Range("A:CX")

    INTO

    Please Login or Register  to view this content.
    But if we want one search only, you need to delete this line

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor tehneXus's Avatar
    Join Date
    04-12-2013
    Location
    Hamburg, Germany
    MS-Off Ver
    Work: MS-Office 2010 32bit @ Win8 32bit / Home: MS-Office 2016 32bit @ Win10 64bit
    Posts
    944

    Re: Search Code vba return to the new sheet with duplicate data

    Hi,

    in the above code are searching for the string in "A:CX", you could first search for a specific column header and then only search for the string in that column, or you could leave the search loop after the first finding.
    Please use [CODE]-TAGS
    When your problem is solved mark the thread SOLVED
    If an answer has helped you please click to give reputation
    Read the FORUM RULES

  4. #4
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: Search Code vba return to the new sheet with duplicate data

    The reason is I really want to search everything. Is there a code that can combine with this code but do the remove duplicate after the search is done?

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Search Code vba return to the new sheet with duplicate data

    As you are searching in entire column G, once the code finds the first match, it will go in to next match
    which is this line, so if you want to the code to find the first match only, you do not need the code to go in to next search.
    Set rFind = .FindNext(rFind)

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Search Code vba return to the new sheet with duplicate data

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If posting code please use code tags, see here.

+ 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