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?![]()











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks