#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default CASE

I want to do something similar to CASE in SQL. That is if cell A1 is 'A' then
I went 'ACTIVE' in B1. if cell A1 is 'D' then I went 'DELETED' in B1. if cell
A1 is 'C' then I went 'CLOSED' in B1.

How to do this?
  #2   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default CASE

One way ..

Put in B1:
=IF(A1="","",VLOOKUP(A1,{"A","ACTIVE";"D","DELETED ";"C","CLOSED"},2,0))
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"GregNga" wrote:
I want to do something similar to CASE in SQL. That is if cell A1 is 'A' then
I went 'ACTIVE' in B1. if cell A1 is 'D' then I went 'DELETED' in B1. if cell
A1 is 'C' then I went 'CLOSED' in B1.

How to do this?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default CASE

Could you possibly explain how this logic works. I looked up VLOOKUP on MS
help and it's not very clear

Thanks again

"Max" wrote:

One way ..

Put in B1:
=IF(A1="","",VLOOKUP(A1,{"A","ACTIVE";"D","DELETED ";"C","CLOSED"},2,0))
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"GregNga" wrote:
I want to do something similar to CASE in SQL. That is if cell A1 is 'A' then
I went 'ACTIVE' in B1. if cell A1 is 'D' then I went 'DELETED' in B1. if cell
A1 is 'C' then I went 'CLOSED' in B1.

How to do this?

  #4   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default CASE

"GregNga" wrote:
Could you possibly explain how this logic works...


VLOOKUP(A1,{"A","ACTIVE";"D","DELETED";"C","CLOSED "},2,0)

The fixed table_array used in the vlookup, ie:
{"A","ACTIVE";"D","DELETED";"C","CLOSED"}

is the same as a 2 col x 3 row range on the sheet:

A ACTIVE
D DELETED
C CLOSED

The lookup value in A1 is compared with the values within the 1st col above,
and where it matches exactly*, the corresponding value in the 2nd** col will
then be returned by the vlookup

*exact matching is specified by the last zero (or FALSE) in the
vlookup(..,2,0)
**that's the col index num: 2 in the vlookup(..,2,0)
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change mixed case to upper case in Excel for all cells WordAlone Network Excel Discussion (Misc queries) 7 May 30th 07 05:53 AM
Change the text from lower case to upper case in an Excel work boo dave01968 Excel Discussion (Misc queries) 2 December 9th 05 09:09 AM
How do I change a column in Excel from upper case to lower case? Debbie Kennedy Excel Worksheet Functions 3 May 2nd 05 06:57 PM
How do I change existing text from lower case to upper case CT Cameron Excel Discussion (Misc queries) 2 November 30th 04 01:07 AM
How to use formula auditing to change upper case to Title Case. ScoobeyDoo Excel Worksheet Functions 1 November 19th 04 06:26 PM


All times are GMT +1. The time now is 06:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"