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.
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,948
Office Version
  1. 365
Platform
  1. Windows
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")
 

Watch MrExcel Video

Forum statistics

Threads
1,122,842
Messages
5,598,396
Members
414,235
Latest member
sucosama

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
Top