Leading Zero

Sylvan

New Member
Joined
Nov 11, 2010
Messages
29
Got a UDF I'm working on and I need a variable to contain a leading zero if it's less than 10. For the leading zero I'm trying the following with no success.

i132 = Format(Split(d32, ".")(0),"00")

Any other ideas?

Thanks
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
How is the i132 variable declared? It must be either a String variable or a Variant varialbe in order to be able to hold leading zeroes. Your code would should work for either of these type declarations. However, if you end up assigning it to a numeric variable or to a cell formated as General or numeric, then the leading zeroes would be lost (numbers do not have "format" and so they cannot have leading zeroes). You didn't give us enough information as to what is happening, so that is the best I can do for you at the moment.
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

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