Excel Macro for Searching Keywords in One Excel Work Book and Copy Entire Rows Having Those Keywords in Another Work Book

Saad Siddiqui

New Member
Joined
May 2, 2021
Messages
4
Office Version
  1. 2010
Platform
  1. Windows
Hello...

I need help with Excel VBA/Macros. I have an excel file in which the the first sheet has a list of keywords and the second sheet has a database in which I want to search those keywords. I want an excel macro when run should search all those keywords in the database and copy all the rows in which those keywords are present. A new workbook should be created when the macro is run in which their are separate sheets for each keyword with data having those keywords.

The list of keywords can change and it should be dynamic. I can add more keywords in the list or I can delete some of them. Additionally, data is also not fix. It can change and I should have the possibility of searching the list of keywords in any other data that I copy in the second sheet of database I mentioned above.

I dont know how to attach the excel file over here as it is not showing the option for it. If someone can guide me, I can attach a sample file for better understanding.

An urgent response in this regard will be highly appreciated.

Thanks
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,723
Office Version
  1. 2010
Platform
  1. Windows
Hi,​
link your workbooks with a files host website …​
As a reminder 'urgent' is not appropriate on any forum where people help on their freetime for free !​
 

Saad Siddiqui

New Member
Joined
May 2, 2021
Messages
4
Office Version
  1. 2010
Platform
  1. Windows
Hi...

Thanks for the response. I am sorry. You are right about it. I will take care of it. Thanks for pointing this out. How can I send the samples files related to this? Cant I upload it over here?
 

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,723
Office Version
  1. 2010
Platform
  1. Windows
You have here the 'XL2BB' tool or just use a files host website …​
 

Saad Siddiqui

New Member
Joined
May 2, 2021
Messages
4
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

Here is the link to Google Drive where I have uploaded the sample file.

 

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,723
Office Version
  1. 2010
Platform
  1. Windows
In which column of the database - can't be as this is Excel ! - Sheet2 must be searched the keywords as the less columns the faster ?​
 

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,723
Office Version
  1. 2010
Platform
  1. Windows

ADVERTISEMENT

As your Sheet2 does not respect Excel rules - no headers - one 'fast' and maybe the easiest way can not be used !​
Using any database software is the smart way as at least 50 times faster than under Excel (10 minutes, 20, 30, ?) …​
 

Saad Siddiqui

New Member
Joined
May 2, 2021
Messages
4
Office Version
  1. 2010
Platform
  1. Windows
Hi Marc

Regarding specific column in Sheet 2 to search for keywords, we can make the macro in a manner where we can just define the column number in the coding to search keywords in. This will make sure that we can change the column number in the coding of macro before running it if we want to search in a different column later on.

Regarding absence of headers in the database, you can just type in the headers as alphabets for the time being in order to use the easiest and fast way you mentioned in your message.

Thanks
 

Marc L

Well-known Member
Joined
Apr 5, 2021
Messages
1,723
Office Version
  1. 2010
Platform
  1. Windows
Regarding absence of headers in the database, you can just type in the headers as alphabets for the time being in order to use the easiest and fast way you mentioned in your message.
You can do it then attach the new sample workbook …​
Whatever the method using numbers or names I won't guess which are the columns to search within !​
The more columns, the slower … The more rows, the slower … The more keywords, the slower …​
As with the very bad idea to use Excel like a database software according to your sample workbook​
it should need more than half an hour and could be twice more if the search is on all columns …​
 

Forum statistics

Threads
1,147,559
Messages
5,741,817
Members
423,689
Latest member
Jords998

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top