Creating a macro to formatt data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

I have a long colum of data in the following format xxxxx, I require the
data to have five zeros before the number.

Example 12345 must be changed to display as 0000012345
 
-> Select the cells you want
-> Click on "Format" menu
-> Click "Cells"
-> Click on "Number" tab
-> Select "Custom" from "Category" list-box
-> Type "000000" in "Type:" textbox
-> Press "OK" Button

*** Please do rate ***
 
You can format it so it displays with a total of 10 digits

If you want it to actually contain 10 digits, then you will have to store it
as a text string

Sub FixData()
Dim cell as Range, s as String
for each cell in Select
s = "00000" & format(cell,"00000")
cell.Value = "'" & s
Next
End Sub
 

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

Back
Top