I would like to have a quick single line VBA code to pad a number in string form to always have a length of a multiples of 3's.
For example:
"12" becomes "012"
"1234" becomes "001234"
"1234567" becomes "001234567"
"12345678912345678" becomes "012345678912345678"
and so on.
The number string will not have any fraction or decimal points, so not to worry about that.
The length of the resulting string should be a multiple of 3 by adding 0's to the Left.
The number string should remain a string throughout the coding and should not be converted into a number using a numeric function such as Val, as the original string could be very long over 150 digits and using a numeric function could truncate or round the number and give undesirable results.
I had come up with the following as a possible solution by checking the string length but feel there is a better more efficient way of doing it in one (1) coding statement.
Please Login or Register to view this content.
Thanks in advance.
Bookmarks