How to display the value in different format?

E

Eric

There is a number in cell A1, which is selected from a list
0.01, 0.1, 1, 10, 100, 1000
There is a given number 654.356 in cell B1
Does anyone have any suggestions on how to display the value in different
format?
For example,
If the number in cell A1 is 0.01, then 654 should be displayed in cell C1.
If the number in cell A1 is 0.1, then 654 should be displayed in cell C1.
If the number in cell A1 is 1, then 654 should be displayed in cell C1.
If the number in cell A1 is 10, then 654.3 should be displayed in cell C1.
If the number in cell A1 is 100, then 654.36 should be displayed in cell C1.
If the number in cell A1 is 1000, then 654.356 should be displayed in cell C1.
Does anyone have any suggestions?
Thanks in advance for any suggestions
Eric
 
B

Bernie Deitrick

Eric,

In C1:

=ROUND(B1,IF(A1<>0,MAX(0,LOG(A1)),0))

I'm guessing that if A1 is 10, you really want 654.4 (?)

HTH,
Bernie
MS Excel MVP
 
B

Bernd P

Hello Bernie,

Of course your approach is shorter.

One variant:
=ROUND(B1,MAX(0,LOG(A1)))

Regards,
Bernd
 
E

Eric

Thank you very much for suggestions
I would like to change the display format by using Text function, rather
than change its value. If I change it value without changing the display
format, the cell would not display 654.4 in cell C1, if the cell format does
not display any decimial 654.
Do you have any suggestions?
Thank you very much for any suggestions
Eric
 
B

Bernie Deitrick

Eric,

The TEXT function also changes the value, just as the ROUND function does.
The value in cell B1 is not changing - just the value as displayed in C1.
So, I'm not sure what end result you want.

Perhaps?

=TEXT(B1,"0" & IF(A1>1,"."& REPT("0",LOG(A1)),""))


Bernie
 
E

Eric

When the question is solved by Round function, it works on the actual values,
but does not work on display format, if the cell is set to display no
decimals at all, even through the actual value is 653.456, but it will
display 653. By using Text function, it will solve my problem in one more
step on showing the decimal without concerning the cell format.
Thank everyone very much for suggestions
Eric
 
S

Shane Devenshire

Hi,

An ever so slightly shorter, and maybe easier, formula would be:

=TEXT(ROUND(B1,IF(A1>1,LOG(A1))),"General")

Cheers,
Shane Devenshire
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top