Format a result

F

Fred

Hi
I'm concatenating several cells into one cell. I need the one value to
display a total of 12 characters long. However, teh cell value may consist
of anywhere from 4 - 12 digits. How can I get the results to display in a
cell to be left aligned, with any unused characters to be displayed as
"spaces" to the right of the digits? (123456789 )

I've tried format(AcctNum, "000000000000"), but it shows all 12 characters
as a number or a zero. (000123456789)

If I use format(AcctNum, "############"), it only shows the characters used,
and no extra characters are entered. If the AcctNum is only 6 characters
long, only 6 characters are used, and I need 12 characters. (123456789)

If I use format(AcctNum, " "), it only enters in 12 spaces,
nothing else. ( )

Thank you.
Fred
 
D

Dave Peterson

Dim AcctNum As Long
AcctNum = 1234
MsgBox "**" & Left(AcctNum & Space(12), 12) & "**"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top