Monday 27 March 2017

Concatenating with Left padded Zeros in MS Excel




You can use the formatting options in the TEXT() function. The syntax is TEXT(value, format_text), so in your example you'd use a formula like:
=TEXT(A1,"00000")
To join the two numeric strings together
=CONCATENATE("1027", TEXT(A1,"00000"))
See: http://office.microsoft.com/en-us/excel-help/text-function-HP010062580.aspx
 

 
 OR
 
The right function will do what you want, if you put a bunch of zeroes before your number. If you want 5 digits total, you'd do something like this:
=right("00000" & 45, 5)
This would output 00045.
If you are putting another number before it, you can just keep concatenating, like this:
=1027 & right("00000" & 45, 5)
You can, of course, replace any of those values with cell references to make it all more dynamic.
 

No comments:

Shrinking the size of Oracle Virtual Box

First, zero fill your virtual disk. Boot the VM and run: sudo dd if=/dev/zero of=/bigemptyfile bs=4096k status=progress sudo rm -f /bigempty...