How do I format cells to show GB, MB, KB

Dickison

Board Regular
Joined
Jun 12, 2002
Messages
75
How do I format cells to show a number entered as 18,177,538,430 to display as 18.2GB
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Given your example, this custom number format would do that:
#,##0.0,,,"GB"

Select the cell(s) of interest, then click Format > Cells > Number tab, select Custom in the Category pane, and enter said custom format in the narrow Type field to the right. Click OK to exit the Format Cells dialog and you should have what you want, at least where your example is concerned.
 
Upvote 0
Thanks. That worked great for GB. Is there a way to get it to put in GB, MB, KB as the size of the number changes?
 
Upvote 0
If you want the format with those text suffixes to change depending on the ranges of the numbers, you will need VBA if it is such that any size number can be present in any given cell. If some cells will always have a certain size number, then you can apply native custom formatting such as I posted to each respective range depending on the expected number range you designed for that cell range.

Instead of providing your information post by post in bits, please just state all the relevant details of how your sheet is designed so we can know the entire picture without guessing:

(1)
How do the numbers get there in the first place...are they manually entered or are they returned by formulas in those cells?

(2)
Will one range of cells always be expecting a certain size number, or can any size number possibly be present in any cell? Example, is column A only for GB, column B only for MB, and column C only for KB. Or can any cell in maybe column A be subject to a certain sized number and hence you want that respective suffix to apply to its formatting depending on number size.

(3)
What is the range of numbers in each case? Example, for GB, what is the lowest size (minimum) number and what is the highest size (maximum) number for which GB would apply, and also then what are the mins and max's for MB and KB suffixes.
 
Upvote 0
Dickison said:
Thanks. That worked great for GB. Is there a way to get it to put in GB, MB, KB as the size of the number changes?
Hi Dickinson:

Let us have a look at ...
Book1
ABCDE
1
2181800018000000
318KB18000MB18000000GB
4CustomNumberFormat[<1000]#"KB";[>1000000]#"GB";#"MB"
5
Sheet3


Would this do?
 
Upvote 0
Sorry about not posting all the details. What I'm doing is keeping track of disk space on all our servers. I have a utility, Dameware, that I export the disk sizes and free space for all the servers. I then import the .csv file created from Dameware, which shows disk info in bytes. I then use the info imported in a weekly report that lists the servers, disk size, free space, and percent free.

This is the format of the import file:

ServerName, Drive, Format, Size Free, Used, PercentFree, PercentUsed
Server1, C: NTFS, "36,314,603,050", "26,413,903,780", "9,901,709,870", 72.73, 27.27
Server1, D: NTFS, "181,819,397,078", "173,242,532,804", "8,567,761,834", 95.29, 4.71

Let me know if you need additional info.
 
Upvote 0
Dickison said:
Sorry about not posting all the details. What I'm doing is keeping track of disk space on all our servers. I have a utility, Dameware, that I export the disk sizes and free space for all the servers. I then import the .csv file created from Dameware, which shows disk info in bytes. I then use the info imported in a weekly report that lists the servers, disk size, free space, and percent free.

This is the format of the import file:

ServerName, Drive, Format, Size Free, Used, PercentFree, PercentUsed
Server1, C: NTFS, "36,314,603,050", "26,413,903,780", "9,901,709,870", 72.73, 27.27
Server1, D: NTFS, "181,819,397,078", "173,242,532,804", "8,567,761,834", 95.29, 4.71

Let me know if you need additional info.
Hi Dickison:

Let us have a look at ...
Book1
ABCDEFGH
1
2ServerName,Drive,Format,SizeFree,Used,PercentFree,PercentUsed
3Server1C:NTFS363146030502641390378099017098772.7327.27
4Server1D:NTFS36.315GB26.414GB990.171MB95.294.71
5CustomNumberFormat[>1000000000]0.000,,,"GB";[>1000000]0.000,,"MB";0.000,"KB"
6
Sheet3 (2)


I hope this helps!
 
Upvote 0
I copied and pasted this

[>1000000000]0.000,,,"GB";[>1000000]0.000,,"MB";0.000,"KB"

It gives an error saying that this format cannot be used. I am using Excel 2003.

Looking in the help file it shows '>' instead of '&gt'. I replaced those and the &nbsp with a space but it's not quite working yet. I'm trying to get TB in also. This is what I have:

[>1000000000000]0.000,,," TB";[>1000000000]0.000,,," GB";[>1000000]0.000,,," MB"

What's wrong with it?
 
Upvote 0
Dickison said:
I copied and pasted this

[>1000000000]0.000,,,"GB";[>1000000]0.000,,"MB";0.000,"KB"

It gives an error saying that this format cannot be used. I am using Excel 2003.

Looking in the help file it shows '>' instead of '&gt'. I replaced those and the &nbsp with a space but it's not quite working yet. I'm trying to get TB in also. This is what I have:

[>1000000000000]0.000,,," TB";[>1000000000]0.000,,," GB";[>1000000]0.000,,," MB"

What's wrong with it?
Hi Dickison:

Let us have a look at ...
Book1
ABCDEFGH
1
2ServerName,Drive,Format,SizeFree,Used,PercentFree,PercentUsed
3Server1C:NTFS10000000000002641390378099017098772.7327.27
4Server1D:NTFS1.000TB26.414GB990.171MB95.294.71
5CustomNumberFormat[>999999999999]0.000,,,,"TB";[>999999999]0.000,,,"GB";0.000,,"MB"
6
Sheet3 (3)


CustomNumberFormat for cells D4,E4, and F4 is ...
Code:
[>999999999999]0.000,,,,"TB";[>999999999]0.000,,,"GB";0.000,,"MB"
Let me know how it works out for you now!
 
Upvote 0

Forum statistics

Threads
1,223,362
Messages
6,171,639
Members
452,412
Latest member
MitchAgain

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