Excel: if my cell contains this text or that text

Solved
Valerieh34 Posted messages 16 Status Member -  
Valerieh34 Posted messages 16 Status Member -
Hello everyone,

I have a slight issue that I would like to resolve with a formula.
If my cell A1 contains the text "ABC" then write ABC in cell B1, or if my cell A1 contains the text "123" then write 123 in B1.
Knowing that I found the first condition with the function in B1
=IF (COUNTIF (A1;"*ABC*");"ABC";"")

How can I do this?
Thank you for your help
Valerie

2 answers

  1. Frenchie83 Posted messages 2254 Status Member 339
     
    Hello
    =IF(COUNTIF(A1,"*ABC*"),"ABC",IF(OR(COUNTIF(A1,"*123*"),COUNTIF(A1,"123"),COUNTIF(A1,"*123"),A1=123),123,""))
    Best regards
    12
    1. Valerieh34 Posted messages 16 Status Member 4
       
      Thank you
      It seems to be getting closer to what I'm looking for
      Actually, I poorly phrased my question.
      I have a total of 10 possibilities
      Cell A1 can contain the character ABC or 123 or DEF or ...
      In cell B1, depending on the type of character being searched for, I need to find it there
      Thanks again if you can shed some light on this
      0
    2. Valerieh34 Posted messages 16 Status Member 4
       
      I found
      =IF(COUNTIF(A1,"*ABC*"),"ABC",IF(COUNTIF(A1,"*123*"),123,IF(COUNTIF(A1,"*DEF"),"DEF","X")))
      Thank you very much for your help
      Best regards
      Valérie
      4