web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

Excel Snippets: Formula to Zero Pad to 6 Digits

Ian Grieve Profile Picture Ian Grieve 22,784
MicrosoftI might not post many Excel snippets, but I’m collecting them into a small Excel Snippets series to make them easy to find.

A colleague posted an Excel formula which could be used to zero pad a column in Excel, which was to be used as the ID column for data being integrated to Microsoft Dynamics 365 Business Central. The formula they had used was longer and more convoluted than was needed.

In fact you only need to use one function to zero pad. That function is TEXT which you provide with two parameters; the cell you want to zero pad and a string of zeros, the length of the output required.

So, to zero pad cell A2 with 6 zeros we would use the following:

=TEXT($A2, "000000")

You can also use the REPT function to provide the required zero [adding length, which if you’re dealing with a long string can ease readability).

The REPT function takes two parameters; the first is the character to repeat and the second is the number of times to repeat:

=TEXT($A2 ,REPT("0", 6))

Read original post Excel Snippets: Formula to Zero Pad to 6 Digits at azurecurve|Ramblings of an IT Professional


This was originally posted here.

Comments

*This post is locked for comments