Avatar of Murphy1992
Murphy1992 asked on

Excel 2010 - Remove all "0" field prefixes

Hi
From a Supplier's site we are able to download our monthly statements in a csv or excel format.  Either works well with the exception that the file applies a varying number of "0" prefixes to the invoice numbers.  

This Supplier's statement is a consolidation of numerous Suppliers invoices for the month - there in lies the problem.  The invoice numbers remain the same as supplied by individual supplier but once consolidated to a single Supplier statement all invoice numbers are padded to a length of 20 characters.  Depending on the individual supplier invoice numbering (can be alpha numeric) will depend on the number of "0" prefixes applied to make it up the single Supplier statement length of 20 characters.

i.e. the number of the "0" prefixes applied to each invoice vary from 1 up to 16.

Any suggestions on how to easily remove these?

We have tried the obvious solutions such as search and replace & length formulas.
Sample-0-Prefix.xlsx
Microsoft Excel

Avatar of undefined
Last Comment
Doug

8/22/2022 - Mon
SOLUTION
Kavi Pachkawade

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Ryan Chong

you may try use a regular expression to remove the leading zeros, like:

Function trimStart(v)
    Dim regex As Object
    Set regex = CreateObject("VBScript.RegExp")
    
    With regex
      .Pattern = "^0+(?!$)"
      .Global = True
    End With
    
    trimStart = regex.Replace(v, "")
End Function

Open in new window


then apply it like:
=trimStart(E2)

Open in new window

Sample-0-Prefix_b.xlsm
ASKER CERTIFIED SOLUTION
Ryan Chong

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Doug

Wouldn't it work to just format the column as a number or as general?
Your help has saved me hundreds of hours of internet surfing.
fblack61