How to Remove Leading Zeros From Alphanumeric Text String in Excel?


Have you ever had to deal with alphanumeric numbers that have extra leading zeros in your computations or that make it tough to work with your data? So don't worry anymore! This step-by-step tutorial will show you how to eliminate those annoying leading zeros, helping you clean up your data and organise your Excel files. We have you covered whether you're working with product codes, serial numbers, or any other alphanumeric data. We'll effectively remove those leading zeros using Excel's built-in functions and a few practical strategies, leaving you with clear and manageable data.

Remove Leading Zeros From Alphanumeric Text String

Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to know how you can remove leading zeros from alphanumeric text strings in Excel.

Step 1

Consider an Excel sheet where you have a list of alphanumeric texts leading with zeros, similar to the below image.

First, right-click on the sheet name and select View code to open the VBA application.

Right-click > View Code.

Step 2

Then click on Insert and select Module, then copy the below code into the text box.

Insert > Module > Copy.

Code

Function RemoveLeadingZeros(Str As String)
   Do While Left(Str, 1) = "0"
      Str = Mid(Str, 2)
   Loop
   RemoveLeadingZeros = Str
End Function

Step 3

Then close VBA using Alt + Q. Then click on an empty cell and enter the formula as =removeleadingzeros(A2) then click enter. Then drag down using the auto fill handle.

Alt + Q > Empty Cell > Formula > Enter > Drag.

This is how you can remove leading zeros from alphanumeric texts in Excel.

Conclusion

In this tutorial, we have used a simple example to demonstrate how you can remove leading zeros from alphanumeric text strings in Excel to highlight a particular set of data.

Updated on: 08-Sep-2023

167 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements