(Solved) – Search multiple worksheets for a user given keyword, return the row results of all instances

  • by
(solved)-–-search-multiple-worksheets-for-a-user-given-keyword,-return-the-row-results-of-all-instances

I am trying to search multiple worksheets for a keyword. If the keyword is found in the worksheet, I would like to return the row results in a listbox.

Here is what I am trying:

Dim wb as ThisWorkbook
Dim ws as Worksheet
Dim keyword as variant

keyword = ItemSearchForm.KeywordTextBox.Value

For each ws in ThisWorkbook
       If keyword = 'any value in the cells below the column headings' Then
       Populate a listbox with these row results
       Else
       MsgBox ("Please insert a valid keyword")
       End if

Next

Is this the right idea? And if so, how can I fix it?

The user selects a criteria (maybe title of a book or a certain year something was made) on the ItemSearchForm, then a textbox appears asking for a keyword (could be a string for a name or a integer for a year or IDNumber), then a listbox appears with the results, all in the same form.

Leave a Reply

Your email address will not be published. Required fields are marked *