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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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
 
Upvote 0

Forum statistics

Threads
1,215,359
Messages
6,124,488
Members
449,166
Latest member
hokjock

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