condition based on value of part of a cell

cpra3617

Board Regular
Joined
May 24, 2007
Messages
62
How would I modify this snippet

Code:
...
If UCase(.Range("A1").Value) = "labo" Then
...

so that the condition would be true even if only part of the cell contained the string "labo"? So, for example, I would like the condition to return true if the cell contained the words "TWO PLACE HOLDERLABO" . The "labo" may exist in different positions within the cell so variations on:

Code:
If UCase(Left(.Range("A1"), 4)) = "labo"

would not work, so far as I am aware.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,318
I think your example got the UCase backwards. It sounds like
Code:
If UCASE(.Range("A1").Value) = "LABO" then
is what you wanted.

About the partial situation:
Code:
If InStr(UCase(.Range("A1").Value)),"LABO") = 0 Then
    MsgBox "LABO is not in a1"
Else
    MsgBox "labo is somewhere in A1"
End IF
 

Forum statistics

Threads
1,181,723
Messages
5,931,679
Members
436,798
Latest member
spprtpplcm

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