identify a cell that contains spedific text

Lenna

Active Member
Joined
Jun 25, 2014
Messages
269
I need to identify cells in row Q that contain words "Donor"/"donor" or "Transplant"/"transplant" either in the beginning or in the middle of a sentence. The following line of code looks for an exact match. If there are other words in a cell it doesn't find it. Please alter this line so it allows for other text to be present in a cell

Thank you


Cells(x, 17).Value = "Donor" or Cells(x, 17).Value = "Transplant"</pre>
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
C2 = Tim buck two Donor
C3 = Tommy needs a Transplant

=OR(ISNUMBER(FIND("Donor",C2)),ISNUMBER(FIND("Transplant",C2)))
=OR(ISNUMBER(FIND("Donor",C3)),ISNUMBER(FIND("Transplant",C3)))


Result of formula = True for both
Does this help?
 
Upvote 0
C2 = Tim buck two Donor
C3 = Tommy needs a Transplant

=OR(ISNUMBER(FIND("Donor",C2)),ISNUMBER(FIND("Transplant",C2)))
=OR(ISNUMBER(FIND("Donor",C3)),ISNUMBER(FIND("Transplant",C3)))


Result of formula = True for both
Does this help?

You need to use SEARCH for non-case sensitive.
 
Upvote 0
This is a formula, not VBA code. I was adding on to the post from Tfox2791 above:

=OR(ISNUMBER(SEARCH({"donor","transplant"},C2)))

Assuming you have text values in column C starting at row 2... Otherwise change C2 to the cell reference where the text is located, and copy down.
 
Upvote 0

Forum statistics

Threads
1,213,490
Messages
6,113,956
Members
448,535
Latest member
alrossman

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