View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default Probably a Stupid Question

If you data starts in cell A1, use this formula in B2:

Sorry - I should have said cell A2....


HTH,
Bernie
MS Excel MVP


"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Paige,

If you data starts in cell A1, use this formula in B2:
=IF(LEFT(A2,1)="0",MID(A2,2,LEN(A2)),A2)
and copy to the left for as many columns as you might have leading zeros (it takes 4 columns of
formulas to remove 4 leading zero characters), so you may have to insert extra columns.

Then copy the last column of results and paste as values over the original data, and then remove
the columns of formulas.


Or select all the cells, and run this macro:

Sub RemoveLeadingZero()
Dim myC As Range
For Each myC In Selection
While Left(myC.Value, 1) = "0"
myC.Value = Mid(myC.Value, 2)
Wend
Next myC
End Sub


HTH,
Bernie
MS Excel MVP


"Paige" wrote in message
...
I have data formatted as text, with leading zeroes, such as 00AF234, 014F,
etc. Is there a way to remove these leading zeroes (other than VB)? The
data could be of any length and have 0, 1, 2 or more leading zeroes. Can't
do find/replace because other zeroes (like in the middle of the data) would
also be removed. Nothing I've tried seems to work, short of sorting by
length, then doing =right. Any ideas please?