custom number format cells based on text

livermore

New Member
Joined
Feb 23, 2011
Messages
39
Hi.

Is it possible to custom number format a cell based on text?

For example, I have a column with a bunch of people names.
What I want is based on the name written, the cell will only allow a 2 digits number or a 4 digit number.

I tried something like =TEXT(A1;"VLOOKUP(C1;$D$1:$E$10;2)"), but I had no luck.

I thought using the VLOOKUP so I could use the format "0.00" and "0.0000" for each person name, so the text function would recognize the format, but apparently I was wrong.

Any help?

Regards.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
with a number 12 in a1, and '0000 in A2 preceded by a single quote to make it a string then

=text(A1,A2) gives 0012, so appears to work for me, maybe you need to remove the double quotes around the VLOOKUP
 
Upvote 0
Hi.

Maybe TEXT is not the right function to do what I want :confused:

Another example:
In A1 I have written Peter and in A2 I have written John.
When I write in B1, I want that cell to be able to recognize Peter's name and know that in that cell, can only be written 2 digit numbers, for example, 33.26. If I write 2.3254 the cell only will accept 2.32.
In B2, that cell must recognize John's name and know that in that cell can only be written 4 digit numbers, for example, 6.3214. If I write 1.23, the cell will add 2 zeros to the number so it can have the 4 digits.

This is what I wanted to do.
I cannot transform the number into text since I need them to do some calculations.

Is it possible?

Regards
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,572
Members
452,927
Latest member
whitfieldcraig

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