3

I am looking for a short way to type this:

=if(a1=1,"sometext",if(a1=2,"othertext",if(a1=3,"thirdtext")))

In JavaScript you would do something similar like this:

switch(a1)
   case 1: "sometext"
   case 2: "othertexT"
   case 3: "thirdtext"

There is formula that can handle multiple values?

3
  • In other words. I am searching for a "conditional text". Like "conditional format"... Commented Jul 23, 2015 at 0:53
  • 1
    Thanks for posting Amina. The VLOOKUP formula is very useful !! If you search Web Applications, you will find multiple cases involving the usage of the VLOOKUP formula: webapps.stackexchange.com/search?q=vlookup. Welcome on Web Applications !!
    – Jacob Jan
    Commented Jul 23, 2015 at 2:08
  • Welcome again......
    – Jacob Jan
    Commented Jul 23, 2015 at 2:17

2 Answers 2

1

Possibly more in keeping with OP's example:

=switch(A1,1,"sometext",2,"othertext","thirdtext")

(using "thirdtext" as the default for anything other than 1 or 2, but inserting 3, would avoid that).

The above does not require a keys/values table but such a table may reduce typing if required often. However in that case two columns (or rows) are required for a VLOOKUP, say:

=vlookup(a1,othersheet!a1:b3,2,false)

which may be abbreviated with a named range to, for example:

=vlookup(A1,Table,2,0)
3

I found how to do it using vlookup.

I have twos sheet. in one sheet I put keys and values

1  somtext
2  othertext
3  thirdtext

In the second sheet

=vlookup(a1,othersheet!a1:a3,2,false)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.