ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a macro to formatt data (https://www.excelbanter.com/excel-programming/371232-creating-macro-formatt-data.html)

ATanker62

Creating a macro to formatt data
 
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



Naveen

Creating a macro to formatt data
 
- 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 ***




"ATanker62" wrote:

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



Tom Ogilvy

Creating a macro to formatt data
 
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

--
Regards,
Tom Ogilvy


"ATanker62" wrote:

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



ATanker62

Creating a macro to formatt data
 
Thanks, the 00000##### works just like I need it to.

"Naveen" wrote:

- 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 ***




"ATanker62" wrote:

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




All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com