Varying left criteria based on 1st Letter....If Function?

S

seve

Hello,

I am using Pivot Tables for Inventory purposes.

I'd like to use a shortened description based on the first letter of
the description.

Can I use an If Statement?


Such as if 1st letter of Description is M - use 1st Left 5 characters,
if 1st letter of description is L - use 1st Left 8 characters?


Steve
 
K

Ken Wright

=IF(LEFT(A1)="M",LEFT(A1,5),IF(LEFT(A1)="L",LEFT(A1,8),"If not then display
this"))

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 97/00/02/03

------------------------------­------------------------------­----------------
It's easier to beg forgiveness than ask permission :)
------------------------------­------------------------------­----------------
 
K

Ken Wright

Or perhaps more scalable:-

=LEFT(A1,VLOOKUP(LEFT(A1),{"L",8;"M",5},2,0))

which can be expanded quite easily to add more letters:-

=LEFT(A1,VLOOKUP(LEFT(A1),{"A",4;"B",5;"C",6;"L",8;"M",5;"X",3;"Y",4;"Z",5},2,0))

Regards
Ken................
 
Top