Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Find Multiple Criteria move active cell up 1

How do I modify this to search for numerous different phrases instead of just one?

Rows(4).Find("Part Number", LookIn:=xlValues, lookat:=xlWhole).Offset(-1) = "CPN"
Cells.Find(What:="CPN").Activate
ActiveCell.Offset(-1, 0).Select
Do something

Instead of searching for just "Part Number", I’d like to search for either, "CPN", "Part Number", "Part Num", "P/N", or "Mfg PN"
Only one of the above phrases will ever be found.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

This code searches for "Part Number" in row 4, in the cell above the found criteria "CPN" is entered.

>Solution :

Just look for all of them:

On error resume next
    Rows(4).Find("Part Number", LookIn:=xlValues, lookat:=xlWhole).Offset(-1) = "CPN"
    Rows(4).Find("CPN", LookIn:=xlValues, lookat:=xlWhole).Offset(-1) = "CPN"
    Rows(4).Find("Part Num", LookIn:=xlValues, lookat:=xlWhole).Offset(-1) = "CPN"
    Rows(4).Find("P/N", LookIn:=xlValues, lookat:=xlWhole).Offset(-1) = "CPN"
    Rows(4).Find("Mfg PN", LookIn:=xlValues, lookat:=xlWhole).Offset(-1) = "CPN"
On error goto 0
Cells.Find(What:="CPN").Offset(-1, 0).Select
Do something
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading