Padding formatted numbers with leading spaces
Your choice:
? "==" & space(10) & "<==="
== <===
? "==" & String(10," ") & "<==="
== <===
--
Regards,
Tom Ogilvy
"Don Wiss" wrote in message
...
On Mon, 10 Jan 2005, gocush wrote:
Don Wiss wrote:
In VBA I'd like to format numbers with a fixed width. I want to pad
blanks
to the front of the formatted number to get to the desired width. I
know
there is a function that returns a desired number of spaces. What is
it?
Then I can write a short function where I format the number, measure
its
width, and then tack on the spaces needed. Or is there an easier way
that
I'm missing? Like a string to give Excel's Format function that makes
it
return a desired width?
If you want to hard-code the range, you can select the range
click: FormatCellsNumberCustom
In the Type: textbox enter 0 for the number of digits you want
Example:
0000000 in the Type box
will make 35 display as 0000035
to do this in VBA try the above with your recorder turned on.
Except my question was about padding with spaces, not zeros.
Don <donwiss at panix.com.
|