To normalize units to Gigabytes (or megabytes, kilobytes, etc.) you can use a clever formula based the MATCH, LEFT, and RIGHT functions. In the example shown, the formula in C5 is:


Note: for simplicity, we are using decimal (base 10) values, but there is a binary standard as well. See below.

Generic formula



Important: This formula assumes that units are the last 2 characters of the text value that includes both a number and a unit of measure.

This formula works because digital units have a "power of 10" relationship. At the core, this formula separates the number part of the size from the unit, then divides the number by the appropriate divisor to normalize to Gigabytes. The divisor is calculated as a power of 10, so the formula reduces to this:


To get the number, the formula extracts all characters from the left up to but not including the units:


To get "power", the formula matches the unit with a hard-coded array constant, {"PB","TB","GB","MB","KB"}:


The result from MATCH is the position of the unit in the array constant. For example, for the formula in C5, the unit is "KB", so the result is 5. This result is adjusted by subtracting 3, then multiplying the result by 3, which yields 6 as the power, which is used as the exponent to calculate the correct result in gigabytes:


Binary standard formula

Computers use the binary number system to store and report data size, but the prefixes like "kilo", "mega", "giga", etc. are based on the metric system. It's a confusing topic, but using decimal units for storage on a computer isn't really correct, and the discrepancy increases as units get larger. The formula below will normalize to binary units.


With this formula, you are technically getting Gibibytes (GiB), not Gigabytes. More information here and here.

Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.