Formatting column

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got an Excel workbook that contains many license numbers and I need to
format the column so that if a license number has several 0s in front, they
aren't automatically truncated by Excel. I tried general, number, and text
formats but they truncate leading 0s. Any ideas? Thanks.
 
You may try running the code below which should effectively remove all
leading zero from the selected cells.

Sub truncate_zero()
Dim cell As Object, tmp
For Each cell In Selection.Cells
tmp = cell.Value
If Left(tmp, 1) = 0 Then
Do Until Left(tmp, 1) <> 0
tmp = Right(tmp, Len(tmp) - 1)
Loop
cell.Value = tmp
End If
Next
End Sub


Regards,
Edwin Tam
(e-mail address removed)
http://www.vonixx.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top