Macro - Find words/terms in cells and paste to new sheet

JoeDelcambre

New Member
Joined
Feb 20, 2022
Messages
16
Office Version
  1. 365
Platform
  1. Windows
I have tried a few macros and they seem to work for the most part. I have attached a Mini Sheet (dummy sheet) to help illustrate.

My goal is to find the following terms: ("Windows 7", "windows 7", "Win 7", "win 7", "XP", "Win XP", "win xp", "windows XP"), then paste the complete rows in which those terms are located to a new sheet (including column titles). The issue I'm running into is some of the keywords I'm looking for are not the only words within a cell. For example, a cell may have "74BBN win 7 TTP77". My current macros are not locating and pasting those rows over to the new sheet, but only the cells with only the exact phrase "win 7" for example.

I decided to start from scratch. Any help is greatly appreciated.






macro tests2.xlsm
ABCDEFGHIJKLMN
1IDMust_PayFundedAgencyDirectorate_IDDivision_IDAcq_PackageOS Amount_Paid Amount_Owed Date_UpdatedStart_DateEnd_DateUpdated_By
2ABC568yesyesUSMCJ6IODUSMC-Package 789vista$ 4,000.00$ 10,000.0012/25/20212/5/20202/1/2022John Smith
3SDJ4478yesnoUSMCJ6CSDUSMC-Package 789XP$ 2,000.00$ 12,000.0011/15/20212/5/20202/2/2022Jane Doe
4LIU9898noyesUSAJ3CSDUSA-Package 3398JTTP4 Windows 7 HWLM$ 3,500.00$ 6,500.003/2/20213/1/20212/3/2022John Doe
5HBR5454yesnoUSAJ3SDDUSA-Package 3398JWin 10$ 2,500.00$ 7,500.006/15/20214/1/20212/4/2022Jane Smith
6NHRI2347yesyesUSNJ2EODUSN-Package 923Windows 10$ 1,200.00$ 10,000.001/22/20225/5/20202/5/2022Jane Smith
7NCUR2458noyesUSCGJ6CIOUSCG-Package 3287Vista$ 6,500.00$ 8,000.001/6/20229/4/20202/6/2022Jane Smith
8LKJ2147noyesUSAFJ3CSDUSAF-Package 776534Win XP$ 2,100.00$ 3,500.007/25/20217/5/20212/7/2022Jane Smith
9POI6698yesnoUSAJ4IODUSA-Package 3398Jwin xp$ 9,800.00$ 12,000.009/2/20214/16/20202/8/2022Jane Smith
10ABCS987nonoUSAFJ1SDDUSAF-Package 776534TTP4 Windows 7 HWLM$ 7,400.00$ 8,000.006/6/20213/1/20212/9/2022Joe Doe
11SMN3298noyesUSSFS4CSDUSSF-Package 2312Windows 7$ 6,500.00$ 9,500.009/22/20217/5/20212/10/2022Joe Doe
12LED8852nonoUSSFS4IODUSSF-Package 2312Windows 10$ 3,500.00$ 3,500.0011/2/20216/7/20202/11/2022John Smith
13LMN326yesyesUSCGS2CSDUSCG-Package 3287Windows XP$ 2,100.00$ 2,500.007/9/20213/1/20212/12/2022John Doe
14WDC589noyesUSNS6CIOUSN-Package 923Win 7$ 1,750.00$ 8,700.002/1/202211/9/20202/13/2022Jane Doe
15VFD365yesyesUSNS6CIOUSN-Package 923Win xp$ 630.00$ 6,500.003/6/20213/25/20202/14/2022Jane Smith
16CVF127yesyesUSMCS3CIOUSMC-Package 78974BBN win 7 TTP77$ 2,500.00$ 3,500.0012/1/20211/6/20212/15/2022Jane Smith
17CVRF9863yesnoUSNJ2SDDUSN-Package 923windows 7$ 7,800.00$ 7,800.002/2/20229/7/20202/16/2022Jane Smith
18MMLK145nonoUSMCJ4IODUSMC-Package 789windows 10$ 9,800.00$ 9,800.003/8/20213/19/20212/17/2022John Doe
19EWD441yesyesUSAFS4CSDUSAF-Package 776534windows XP$ 1,200.00$ 4,500.008/5/20217/7/20202/18/2022John Doe
20RRB2285nonoUSAFS5CSDUSAF-Package 776534Windows 7$ 3,200.00$ 4,500.009/5/20219/3/20202/19/2022John Doe
21ABC568yesorangeabcJ6xyzUSMC-Package 789vista$ 4,000.00$ 10,000.0012/25/20212/5/20202/1/2022John Smith
22SDJ4478yesorangeUSMCJ6CSDUSMC-Package 789XP$ 2,000.00$ 12,000.0011/15/20212/5/20202/2/2022Jane Doe
23LIU9898noyesUSAJ3xyzUSA-Package 3398JWindows 7$ 3,500.00$ 6,500.003/2/20213/1/20212/3/2022John Doe
24HBR5454yesnoabcJ3CSDUSA-Package 3398JWin 10$ 2,500.00$ 7,500.006/15/20214/1/20212/4/2022Jane Smith
25NHRI2347yesbananaUSNJ2EODUSN-Package 923Windows 10$ 1,200.00$ 10,000.001/22/20225/5/20202/5/2022Jane Smith
26NCUR2458noyesabcJ6xyzUSCG-Package 3287Vista$ 6,500.00$ 8,000.001/6/20229/4/20202/6/2022Jane Smith
27LKJ2147noyesUSAFJ3CSDUSAF-Package 776534Win XP$ 2,100.00$ 3,500.007/25/20217/5/20212/7/2022Jane Smith
28POI6698yesappleUSAJ4IODUSA-Package 3398Jwin xp$ 9,800.00$ 12,000.009/2/20214/16/20202/8/2022Jane Smith
29ABCS987nonoabcJ1SDDUSAF-Package 776534Windows 7$ 7,400.00$ 8,000.006/6/20213/1/20212/9/2022Joe Doe
30SMN3298noyesUSSFS4CSDUSSF-Package 2312Windows 7$ 6,500.00$ 9,500.009/22/20217/5/20212/10/2022Joe Doe
31LED8852nonodefS4xyzUSSF-Package 2312Windows 10$ 3,500.00$ 3,500.0011/2/20216/7/20202/11/2022John Smith
32LMN326yesappleabcS2CSDUSCG-Package 3287Windows XP$ 2,100.00$ 2,500.007/9/20213/1/20212/12/2022John Doe
33WDC589noUSNS6defUSN-Package 92374BBN Win 7 TTP77$ 1,750.00$ 8,700.002/1/202211/9/20202/13/2022Jane Doe
34VFD365yesyesUSNS6xyzUSN-Package 923Win xp$ 630.00$ 6,500.003/6/20213/25/20202/14/2022Jane Smith
35CVF127yesappleabcS3xyzUSMC-Package 789win 7$ 2,500.00$ 3,500.0012/1/20211/6/20212/15/2022Jane Smith
36CVRF9863yesnoUSNJ2SDDUSN-Package 923windows 7$ 7,800.00$ 7,800.002/2/20229/7/20202/16/2022Jane Smith
37MMLK145nonoabcJ4IODUSMC-Package 789windows 10$ 9,800.00$ 9,800.003/8/20213/19/20212/17/2022John Doe
38EWD441yesyesUSAFS4CSDUSAF-Package 776534windows XP$ 1,200.00$ 4,500.008/5/20217/7/20202/18/2022John Doe
39RRB2285nonodefS5CSDUSAF-Package 776534Windows 7$ 3,200.00$ 4,500.009/5/20219/3/20202/19/2022John Doe
Sheet1
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Store the terms in a free column like T for example with the same column header then you can use an advanced filter.​
Another way is to hardcode an array for the terms then use a filter with this array as criteria …​
 
Upvote 0
According to your attachment and according to the Macro Recorder using a filter Excel basics a VBA demonstration for starters​
to paste to the data source worksheet module :​
VBA Code:
Sub Demo1()
        Application.ScreenUpdating = False
        If Sheets.Count = Index Then Sheets.Add , Me Else Sheets(Index + 1).UsedRange.Clear
    With UsedRange
        .Columns(8).AutoFilter 1, [{"*Win* 7*","*XP*"}], 7
        .Copy Sheets(Index + 1).[A1]
        .AutoFilter
    End With
        Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:
Upvote 0
I inputted some of that in my macro on the dummy worksheet I posted, and I got it to work. I applied that to the actual project I was working on and it is copying/pasting all 44,000 rows on the new sheet. No idea why.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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
Back
Top