IF Statement

  • Thread starter Thread starter DME
  • Start date Start date
D

DME

IN cell a1 I have CP-Barge

In B1 I want a formula that says IF A1 contains CP then Enter CP into cell
B1otherwise leave it Blank

I have tried =IF(a1="*CP*","CP","") but it does not work.

Thanks for your help
 
=if(left(a1,2)="CP","CP","")

if A1 always starts with the two characters CP.
 
DME said:
IN cell a1 I have CP-Barge

In B1 I want a formula that says IF A1 contains CP then Enter CP int
cell
B1otherwise leave it Blank

I have tried =IF(a1="*CP*","CP","") but it does not work.

Thanks for your help

Will this work for you?

=if(left(A1,2)="CP","CP",""
 
Try this:

=IF(ISERR(SEARCH("*CP*",A1)),"","CP")

HTH,

RD
==============================================
Please keep all correspondence within the Group, so all may benefit!
==============================================


"DME" <craigjoseathotmaildotcom> wrote in message
IN cell a1 I have CP-Barge

In B1 I want a formula that says IF A1 contains CP then Enter CP into cell
B1otherwise leave it Blank

I have tried =IF(a1="*CP*","CP","") but it does not work.

Thanks for your help
 
If you want it case-sensitive, amend RD's formula to
=IF(ISERR(FIND("CP",A1)),"","CP")
 
The problem with using FIND() in this scenario though Bob, is that it
*doesn't* accept wild cards, and to meet the OP's specs, wildcards *are*
necessary.
--


Regards,

RD
 
Why? FIND finds it wherever it is (as does SEARCH). The OP used wildcards,
but I don't see that makes it a requirement. Am I missing something?
 
You're not missing anything!
It's me who's missing brain power.<g>

Funny how that power of suggestion can throw you off.
--


Regards,

RD
 
This is what I need except I needed it nested for several text possibilities.
For example, I need it to find "apples", "oranges", "bananas" or "grapes". I
need the wildcards because these words could be anywhere in a cell.
 
Hi maryj

if it finds "apples" do you want "apples" in B1; if it finds "oranges" do
you want "oranges" in B1 etc?

If so then one option is
=IF(ISERR(SEARCH("*CP*",A1)),IF(ISERR(SEARCH("*apples*",A1)),IF(ISERR(SEARCH("*oranges*",A1)),IF(ISERR(SEARCH("*bananas*",A1)),IF(ISERR(SEARCH("*grapes*",A1)),"","grapes"),"bananas"),"oranges"),"apples"),"CP")

Cheers
JulieD
 
Perfect!! That's just what I needed.

JulieD said:
Hi maryj

if it finds "apples" do you want "apples" in B1; if it finds "oranges" do
you want "oranges" in B1 etc?

If so then one option is
=IF(ISERR(SEARCH("*CP*",A1)),IF(ISERR(SEARCH("*apples*",A1)),IF(ISERR(SEARCH("*oranges*",A1)),IF(ISERR(SEARCH("*bananas*",A1)),IF(ISERR(SEARCH("*grapes*",A1)),"","grapes"),"bananas"),"oranges"),"apples"),"CP")

Cheers
JulieD
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top