Link to home
Start Free TrialLog in
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
SOLUTION
Avatar of Kavi Pachkawade
Kavi Pachkawade
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wouldn't it work to just format the column as a number or as general?