Custom format of numbers

Huffy

New Member
Joined
Dec 10, 2009
Messages
2
Hi all... and many thanks to a lot of the posts I've been through already to help me out!

What I'm looking to do now in my macro is a custom format of a group of cells to display 5 numbers. Example output would be:

10141
04039
00583
92584
35412
99919
00098

The zeros must be displayed. The cells are formatted as numbers, but of course, the zeros that begin the numbers disappear.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Welcome to the Board!

If you format as Text instead of Number, the leading zeroes will not be dropped. Formatting the cells as Text before populating should do the trick, as long as your code isn't trying to insert a number that has already dropped the leading zeroes.

If so, you can convert it in VBA using:
FORMAT(Value,"00000")
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,717
Members
449,050
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top