In EXCEL, how can I use the "=" command, to ALSO bring in the format code used for a cell?

in other words...

Using format codes for the cell...
A1=05
A2=0005


B1=4
B2=if(b1=4;A2;A1)
both results make B2=5

I need it to also return the correct number of characters by replicated the original cell exactly.

?2015-11-30T21:03:35Z

Favorite Answer

Not possible with formulas alone, supposing your values are numeric. Formats are independent, unless you use Conditional Formatting.

If the values are text, set B2 to Text format as well. The exact characters will be copied as they are.

Jeenyus2015-11-30T21:50:59Z

IF(B1=5;TEXT(A1;"00000");IF(B1=4;TEXT(A1;"0000");TEXT(A1;"000")))

THIS WORKED!!! (and I don't even need cell A2!)