Re: Formating output.

From: Rob van Gelder (newsgroups_at_nojunkmail-vangelder.co.nz)
Date: 11/27/04


Date: Sun, 28 Nov 2004 12:55:10 +1300

Pretty neat stuff with the ,,, business.

Just to add a layer of complexity...
There is 1024 bytes to a kilobyte
1024 kilobytes to a megabyte
1024 megabytes to a gigabyte

Though 1000 may well be close enough for the OP.

-- 
Rob van Gelder - http://www.vangelder.co.nz/excel
"Peter T" <peter_t@discussions> wrote in message 
news:eD3MXaN1EHA.3500@TK2MSFTNGP09.phx.gbl...
> Brian,
>
> I think you should be able to format as you wish and retain values for
> summing.
>
> For starters, but not quite what you want:
>
> Sub FileFormat()
> Dim sCustom As String, r as Range
>
> For Each r In Selection
> Select Case r.Value
> Case Is >= 10 ^ 9: sCustom = "#.###,,,"" Gb"""
> Case Is >= 10 ^ 6: sCustom = "#.###,,"" Mb"""
> Case Is >= 10 ^ 3: sCustom = "#.###,"" Kb"""
> Case Else: sCustom = "###"" B"""
> End Select
> r.NumberFormat = sCustom
> Next
>
> End Sub
>
> I'll leave you to adapt to your needs, say:
> change the case values to adapt to your .5 & .75 etc
> reduce the "###", or
> remove the ".",
> replace ### with ".5Kb" or whatever.
> maybe change alignment a little with some spaces in the string
> Add more case's to suit.
>
> When done maybe you can put an event routine.
>
> Regards,
> Peter
>
> "JustSomeGuy" <nope@nottelling.com> wrote in message
> news:uHAKq#L1EHA.2716@TK2MSFTNGP14.phx.gbl...
>> I have a number which is the size of a file on disk.
>> Depending on the size of the number I want to display it as either
>> 1.5KB, or 2.0MB or .75GB or .5TB
>>
>> However I want to be able to add up all the numbers in that column as
> normal
>> numbers and also format it the same way.
>>
>> How do I do this.... I do know VB very well...
>>
>> Brian.
>>
>
>