Results 1 to 13 of 13

Using VBA to search for keywords in data set and return results in another sheet

Threaded View

  1. #1
    Registered User
    Join Date
    08-29-2016
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    13

    Using VBA to search for keywords in data set and return results in another sheet

    Hi everyone,

    Hope you all are doing well. I have this irritating issue with a vba code I am trying to perfect.

    Sheet2 - contains data set

    Sheet1 - search query using keywords entered in cell "H4""

    Essentially I want to search for key words that are entered in sheet1 cell "H4". I am trying the search to take place data set located in Sheet2 column G7:G20000 and H7:H20000. If keywords match any one of cells in Column G or H, then paste that row in sheet1, but only specific columns from the matching row, e.g. Column F, G, H, K and M from sheet2 into Sheet1.

    I am trying to get the pasting down starting in cell "B11" in sheet1

    I also can't seem to have search results cleared every time I run this script.

    I have the following code:

    -------------
    Sub Keyword_search()
        Dim MyFind As Variant
        Dim MyNewValue As Variant
        Dim FoundCell As Object
        Dim Counter As Long
      
        MyFind = Worksheets("Keyword search for a product").Range("H4")
        If MyFind = "" Then End
        Counter = 0
        
    
    
        On Error Resume Next
        Set ws = Worksheets("Classification Requests").Range("H:H")
        Set FoundCell = ws.Cells.Find(what:=MyFind)
        If Not FoundCell Is Nothing Then
            FirstAddress = FoundCell.Address
            Do
                Counter = Counter + 1
          
                FoundCell.EntireRow.Copy Destination:=Sheets("Keyword search for a product").Cells(Rows.Count, 1).End(xlUp).Offset(10, 0)
                
     
                Set FoundCell = ws.Cells.FindNext(FoundCell)
            Loop While Not FoundCell Is Nothing _
                And FoundCell.Address <> FirstAddress
        End If
     
    End Sub
    ------------------

    Can someone please help me clean up this vba?
    Last edited by Rez4ul; 09-02-2016 at 08:36 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Search/find all worksheets return results on new sheet
    By Morleyb in forum Excel General
    Replies: 1
    Last Post: 06-28-2016, 03:51 PM
  2. VBA to search duplicate & return all possible results to Main Sheet?
    By beepbeep_go in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-28-2015, 11:27 AM
  3. [SOLVED] VBA looking for multiple keywords and return concatenated keywords, that were found
    By Kpacu007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-10-2014, 06:03 AM
  4. Search for Keywords and Return the Appropriate Item
    By uberathlete in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-05-2014, 12:52 AM
  5. [SOLVED] Search for keywords and copy rows containing keywords to new sheet
    By lenorsk in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-15-2013, 06:54 AM
  6. [SOLVED] HDI - Return multiple keywords in a text column based on a set of available keywords
    By zneiley in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-25-2013, 01:32 PM
  7. Search a column value and return results to summary sheet while highlighting duplicate val
    By ettiene@icap.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2013, 03:41 AM

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