Smart number formatting

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
2,775
Office Version
  1. 365
Platform
  1. Windows
I have a need to display numbers that are actual Project IDs aligned at the decimal. Some of the PIDs have varying digits before and after the decimal. Could be 3.0, 3.2, 4.0, 4.1, 4.2. I can accomplish this using conditional formatting, but that is cumbersome. Conditional formatting also has a tendency to replicate and mess things up.

Rules:
* No leading or trailing zeros
* Align values at expected decimal
* Whole numbers can't show the decimal
* Use only number formatting

Has anybody accomplished this?


1673468825261.png
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi

Format Personalizzed
0,??
0" "
 

Attachments

  • Immagine.png
    Immagine.png
    41.1 KB · Views: 7
Upvote 0
Why don't you simply format column as General?
 
Upvote 0
This works, but the results need to be in a monotype font like "Lucida Console".

You can't really see it line up below, but after you apply one of those fonts it will look right.

2023 Work Exercise.xlsx
AB
1PIDResult
2156156
3601601
4671671
512.4412.44
61386.221386.22
71388.11388.1
81471.11471.1
Sheet2
Cell Formulas
RangeFormula
B2:B8B2=A2&REPT(" ",3-LEN(TEXT(A2-TRUNC(A2),"@"))+1)
 
Upvote 0
Why don't you simply format column as General?
If some numbers have decimals and some numbers don't (and they don't always have the same number of decimals), they will not line up on the decimal point if you just use the General format.
(Take a look at the Result column in the original post -- that is what he is after).
 
Upvote 0
This is the way I currently achieve the goal:
Standard number formatting: ####.??
Conditional formatting: ####_._?_? With this formula: =A6=INT(A6)

I was hoping not to use conditional formatting

{this has to be right justified}
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,605
Members
449,038
Latest member
Arbind kumar

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