different values in cell (formula too long)

gullit

New Member
Joined
Jul 25, 2011
Messages
17
Hi, i have a problem that i can't see the solution to it.
I have 22 different values that a cell may have. i need a formula where if "cell value = "X" then "xx", the problem is that since a have 22 different possible values, the formula becomes too long and get a message "formula too long". I have past the maximun number of characters allowed
example:
cell value="y" then "X"
"L" then "XXX"
"U" then "XXXX", etc.
How can i work around it?
Any advice will be greatly appreciated.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
If you will use VBA code then you can use Select Case Statement..

like...

Select Case cell.value
case "y"
cell1.value="X"
case "L"
cell1.value="XXX"
.
.
.
case else
cell.value= "whatever"
End select
 
Upvote 0
If you will use VBA code then you can use Select Case Statement..

Heya Villy,

I've got to respectfully disagree with you on this. While a Select Case statement would certainly work, it's also a very static approach, so if there are ever any changes or additions to the conditions, then the Select Case statment needs to be adjusted. This is much more time consuming than a Lookup table. Another point would be not to use VBA if a native solution will suffice, because VBA will almost always be slower.

My 2 cents anyway. ;)
 
Upvote 0
Thank you very much, i will try both suggestions, but i believe VLOOKUP will do.. i was trying the IF formula.....duh!!...sometimes when
u see the problem from the outside the answer is right in your face. Thanks a lot for the quick help. This forum rocks!!
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top