excel vba convert number to string with leading zeros code example Example: vba leading zeros in string MsgBox format(12,"0000") ' OUTPUT: 0012