# Auto Change Number Format based on Value

#### ravi2628

##### Board Regular
Hi Friends,

Good Morning, Afternoon, Evening, Night.

I need a formula to change the number format based on value.

Book2
AB
12018Required Format
290,59,801 \$9.06 M\$
37,74,58,292 \$77.46 M\$
472,518 \$72.52 K\$
56,49,64,558 \$64.96 M\$
66,38,11,998 \$63.81 M\$
76,26,30,999 \$62.63 M\$
85,97,96,876 \$59.80 M\$
95,57,48,878 \$55.75 M\$
1053,64,11,476 \$536.41 M\$
1154,83,198 \$5.48 M\$
124,77,24,792 \$47.72 M\$
1343,27,40,344 \$432.74 M\$
1446,21,501 \$4.62 M\$
1545,80,207 \$4.58 M\$
1641,07,698 \$4.11 M\$
173,12,34,452 \$31.23 M\$
1836,50,833 \$3.65 M\$
1935,54,749 \$3.55 M\$
2031,39,004 \$3.14 M\$
212,81,79,772 \$28.18 M\$
222,35,18,408 \$23.52 M\$
232,30,19,762 \$23.02 M\$
2421,48,60,321 \$214.86 M\$
2520,24,55,779 \$202.46 M\$
2626,19,990 \$2.62 M\$
2721,76,375 \$2.18 M\$
282,13,14,10,354 \$2.13 B\$
Sheet1
Cell Formulas
RangeFormula
B2:B28B2=IF(LEN(A2)>=10,TEXT(A2,"#0.00,,,")&" B\$",IF(LEN(A2)>=7,TEXT(A2,"#0.00,,")&" M\$",TEXT(A2,"#0.00,")&" K\$"))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B28Cell Valueending with "K\$"textNO
B2:B28Cell Valueending with "B\$"textNO
B2:B28Cell Valueending with "M\$"textNO

Currently i was change in the value using the following Condition but i need the same logic on cell Format.

because in the cells have a if & sumifs condition so if i add the logic in the same cell the formula becomes critical to under stand for others.

Regards,
Ravi

### Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

#### bobsan42

##### Well-known Member
This I did with Conditional formatting only, so you keep the values for calculation:
MrExcel Playbook 02 2021-09.xlsm
ABC
12018Required FormatCF + NF
2\$ 9 059 801.009059801.00,, M\$9.06 M\$
3\$ 77 458 292.0077458292.00,, M\$77.46 M\$
4\$ 72 518.0072518.00, K\$72.52 K\$
5\$ 64 964 558.0064964558.00,, M\$64.96 M\$
6\$ 63 811 998.0063811998.00,, M\$63.81 M\$
7\$ 62 630 999.0062630999.00,, M\$62.63 M\$
8\$ 59 796 876.0059796876.00,, M\$59.80 M\$
9\$ 55 748 878.0055748878.00,, M\$55.75 M\$
10\$ 536 411 476.00536411476.00,, M\$536.41 M\$
11\$ 5 483 198.005483198.00,, M\$5.48 M\$
12\$ 47 724 792.0047724792.00,, M\$47.72 M\$
13\$ 432 740 344.00432740344.00,, M\$432.74 M\$
14\$ 4 621 501.004621501.00,, M\$4.62 M\$
15\$ 4 580 207.004580207.00,, M\$4.58 M\$
16\$ 4 107 698.004107698.00,, M\$4.11 M\$
17\$ 31 234 452.0031234452.00,, M\$31.23 M\$
18\$ 3 650 833.003650833.00,, M\$3.65 M\$
19\$ 3 554 749.003554749.00,, M\$3.55 M\$
20\$ 3 139 004.003139004.00,, M\$3.14 M\$
21\$ 28 179 772.0028179772.00,, M\$28.18 M\$
22\$ 23 518 408.0023518408.00,, M\$23.52 M\$
23\$ 23 019 762.0023019762.00,, M\$23.02 M\$
24\$ 214 860 321.00214860321.00,, M\$214.86 M\$
25\$ 202 455 779.00202455779.00,, M\$202.46 M\$
26\$ 2 619 990.002619990.00,, M\$2.62 M\$
27\$ 500.00500.00, K\$500.00 \$
28\$ 2 131 410 354.002131410354.00,,, B\$2.13 B\$
Sheet3
Cell Formulas
RangeFormula
C2:C28C2=A2:A28
B2:B28B2=IF(LEN(A2)>=10,TEXT(A2,"#0.00,,,")&" B\$",IF(LEN(A2)>=7,TEXT(A2,"#0.00,,")&" M\$",TEXT(A2,"#0.00,")&" K\$"))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:C28Cell Value>=1000000000textYES
C2:C28Cell Value>=1000000textYES
C2:C28Cell Value>=1000textNO

The when the conditions are met a custom number format is applied depending on the case:
Excel Formula:
``````# ##0.00   \ \B\$
# ##0.00  \ \M\$
# ##0.00 \ \K\$``````

#### ravi2628

##### Board Regular
This I did with Conditional formatting only, so you keep the values for calculation:
MrExcel Playbook 02 2021-09.xlsm
ABC
12018Required FormatCF + NF
2\$ 9 059 801.009059801.00,, M\$9.06 M\$
3\$ 77 458 292.0077458292.00,, M\$77.46 M\$
4\$ 72 518.0072518.00, K\$72.52 K\$
5\$ 64 964 558.0064964558.00,, M\$64.96 M\$
6\$ 63 811 998.0063811998.00,, M\$63.81 M\$
7\$ 62 630 999.0062630999.00,, M\$62.63 M\$
8\$ 59 796 876.0059796876.00,, M\$59.80 M\$
9\$ 55 748 878.0055748878.00,, M\$55.75 M\$
10\$ 536 411 476.00536411476.00,, M\$536.41 M\$
11\$ 5 483 198.005483198.00,, M\$5.48 M\$
12\$ 47 724 792.0047724792.00,, M\$47.72 M\$
13\$ 432 740 344.00432740344.00,, M\$432.74 M\$
14\$ 4 621 501.004621501.00,, M\$4.62 M\$
15\$ 4 580 207.004580207.00,, M\$4.58 M\$
16\$ 4 107 698.004107698.00,, M\$4.11 M\$
17\$ 31 234 452.0031234452.00,, M\$31.23 M\$
18\$ 3 650 833.003650833.00,, M\$3.65 M\$
19\$ 3 554 749.003554749.00,, M\$3.55 M\$
20\$ 3 139 004.003139004.00,, M\$3.14 M\$
21\$ 28 179 772.0028179772.00,, M\$28.18 M\$
22\$ 23 518 408.0023518408.00,, M\$23.52 M\$
23\$ 23 019 762.0023019762.00,, M\$23.02 M\$
24\$ 214 860 321.00214860321.00,, M\$214.86 M\$
25\$ 202 455 779.00202455779.00,, M\$202.46 M\$
26\$ 2 619 990.002619990.00,, M\$2.62 M\$
27\$ 500.00500.00, K\$500.00 \$
28\$ 2 131 410 354.002131410354.00,,, B\$2.13 B\$
Sheet3
Cell Formulas
RangeFormula
C2:C28C2=A2:A28
B2:B28B2=IF(LEN(A2)>=10,TEXT(A2,"#0.00,,,")&" B\$",IF(LEN(A2)>=7,TEXT(A2,"#0.00,,")&" M\$",TEXT(A2,"#0.00,")&" K\$"))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:C28Cell Value>=1000000000textYES
C2:C28Cell Value>=1000000textYES
C2:C28Cell Value>=1000textNO

The when the conditions are met a custom number format is applied depending on the case:
Excel Formula:
``````# ##0.00   \ \B\$
# ##0.00  \ \M\$
# ##0.00 \ \K\$``````
Thanks bobsan.

you logic worked very well

Replies
5
Views
385

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

1,151,611
Messages
5,765,414
Members
425,285
Latest member
andypandypoo

### 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.

### Which adblocker are you using?

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

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