ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how do i eliminate leading 0 in a text cell (https://www.excelbanter.com/excel-discussion-misc-queries/111496-how-do-i-eliminate-leading-0-text-cell.html)

REST

how do i eliminate leading 0 in a text cell
 
I have ID numbers that are alpha numeric. Some are all numeric formatted as
text, others are actual alpha numeric combinations. Most all have leading
"0s". I want to easily eliminate them.

Dave Peterson

how do i eliminate leading 0 in a text cell
 
Select the range
edit|replace
what: 0
with: 0
replace all


REST wrote:

I have ID numbers that are alpha numeric. Some are all numeric formatted as
text, others are actual alpha numeric combinations. Most all have leading
"0s". I want to easily eliminate them.


--

Dave Peterson

Gary''s Student

how do i eliminate leading 0 in a text cell
 
Enter this macro:

Sub zeroplucker()
For Each r In Selection
If Left(r.Value, 1) = "0" Then
Do
r.Value = Right(r.Value, Len(r.Value) - 1)
If Left(r.Value, 1) < "0" Then
Exit Do
End If
Loop
End If
Next
End Sub

Then select the cells you want to fix and run the macro.
--
Gary's Student


"REST" wrote:

I have ID numbers that are alpha numeric. Some are all numeric formatted as
text, others are actual alpha numeric combinations. Most all have leading
"0s". I want to easily eliminate them.



All times are GMT +1. The time now is 03:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com