Friday 25 October 2013

Excel Macro to add leading zero to cell value

'Excel Macro to add leading zero to any cell.


Sub addLeadingZero()

'get the value from cell
x = Sheet1.Cells(1, 1)
'add leading zero

x = "'000" & x

'print value with zero
MsgBox x

'store value back in cell
Sheet1.Cells(1, 1) = x

End Sub

No comments:

Post a Comment

Popular Posts

Search This Blog