Find Text in Range

ddub25

Well-known Member
Joined
Jan 11, 2007
Messages
617
Office Version
  1. 2019
Platform
  1. Windows
How would I write VBA code to do the following:

IF "P1" is evident in Range CX85:CX94 Then
Return "Place..." in CN73
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Assuming that P1 is text and, when present, is the only text in the cell...
Code:
[table="width: 500"]
[tr]
	[td]If Application.CountIf(Range("CX85:CX94"), "P1") Then Range("CN73").Value = "Place..."[/td]
[/tr]
[/table]
 
Upvote 0
Thanks Rick. How do I adapt it further to add the condition that "P2" cannot be evident in the range?

If Application.CountIf(Range("CX85:CX94"), "P1")

And Application.CountIf(Range("CX85:CX94"), DOES NOT CONTAIN "P2")

Then Range("CN73").Value = "Place..."
 
Upvote 0
Code:
If Application.CountIf(Range("CX85:CX94"), "P1") And Application.CountIf(Range("CX85:CX94"), "P2") = 0 Then Range("CN73").Value = "Place..."
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,666
Members
448,977
Latest member
moonlight6

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