I have a series of numbers in Excel that I would like formatted in a certain way and I need some help.
Background:
I work in construction, and am using the Construction Specification Institute's (CSI) Masterformat system of categorizing building materials used in a project. This standardized system works as follows: any type of construction material or assembly is given a 6-digit (or occasionally, 8-digit) code. These digits are structured in a way where the first two digits indicate the overall category of material type (e.g. concrete, metal, masonry, etc), and you get more and more specific as you go down the remaining digits in pairs.
For example, 03 52 16.13
indicates Lightweight Cellular Insulating Concrete
, with the parts being broken down as follows, each progressively getting more specific.
03
00 00 is Concrete
03 52
00 is Concrete Insulation
03 52 16
is Lightweight Insulating Concrete
03 52 16.13
is Lightweight Cellular Insulating Concrete
As you can see, these numbers have a specific formatting that is important to maintain. The rules are as follows:
- RULE 1 — A number must be either 6 digits (e.g.
03 52 16
), OR, 6 digits followed by two decimal digits (e.g.03 52 16.13
) - RULE 2 — Digits must be spaced after every pair. (
03 52 16
is correct,035216
is not) - RULE 3 — For numbers beginning with
0
, the leading zero must be maintained. (03 52 16
is correct,3 52 16
is not) - RULE 4 — Numbers that are six digits only may not have decimal zeroes at the end. (
03 52 16
is correct,03 52 16.00
is not)
Which brings me to my question:
I have a long list of these numbers in an Excel table for my project, which are entered manually (not via formula). How can I set up a universal cell formatting that allows for this?
Examples:
- Typed
12345
-------> Should Become01 23 45
- Typed
123456
------> Should Become12 34 56
(NOT12 34 56.00
) - Typed
123456.78
---> Should Become12 34 56.78
(NOT12 34 56
)
For cell formatting...
00 00 00 .00
would satisfy Rules 1+2+3, but violates Rule 4.
00 00 00 .##
would almost satisfy all four rules, but would leave a strange decimal at the end.
What to do? Is there a way to do this without conditional formatting? Thank you.
00 00 00.00
and then use conditional formatting with formula=LEN(cell_ref)<=6
and format that as00 00 00