The first issue we can help with, but the second is off topic.
You don't need any VBA to format these numbers the way you want, just a
formula and a custom format in the cell. If your number is A1, you need
the following formula in another cell - say B1 - to convert it into a
number with no spaces:
=VALUE(SUBSTITUTE(A1," ",""))
Then you can go to Cells-Format - Number, select 'custom' from the list
box and type ten zeros into the field. You can put any spaces or hyphens
you want between the zeros.