+ Reply to Thread
Results 1 to 6 of 6

How to remove all Zero"0" & space from left side

Hybrid View

nur2544 How to remove all Zero"0" &... 02-01-2013, 03:15 AM
nested.if1@gmail.com Re: How to remove all Zero"0"... 02-01-2013, 03:20 AM
jindon Re: How to remove all Zero"0"... 02-01-2013, 03:32 AM
zbor Re: How to remove all Zero"0"... 02-01-2013, 03:42 AM
:) Sixthsense :) Re: How to remove all Zero"0"... 02-01-2013, 04:08 AM
nur2544 Re: How to remove all Zero"0"... 02-01-2013, 05:37 AM
  1. #1
    Forum Contributor
    Join Date
    06-08-2012
    Location
    BD
    MS-Off Ver
    Microsoft Office 2016
    Posts
    640

    How to remove all Zero"0" & space from left side

    How to delete all zero & space from left side of a particular data with the help of macro

    i have data like below
    000000000000 010080023000
    i want as 10080023000

    Again i have like this
    000000000000 200000000008
    i want like 200000000008

    000000004000 000000000000 = 4000000000000000
    00000000E000 000000000000 = E000000000000000

    000000000020 000040000000 = 20000040000000

    i have lots of data like above in the range (D:J).

  2. #2
    Forum Contributor
    Join Date
    08-23-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: How to remove all Zero"0" & space from left side

    Please upload sample data.

    Also check if the below is helpful.....

    Assuming data is in D1 enter formula =TEXT(SUBSTITUTE(D1," ",""),"0")
    Last edited by nested.if1@gmail.com; 02-01-2013 at 03:33 AM.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: How to remove all Zero"0" & space from left side

    Select the range then run the code
    Sub test()
        Dim r As Range
        With CreateObject("VBScript.RegExp")
            .Pattern = "^0+"
            For Each r In Selection
                r.NumberFormat = "@"
                r.Value = .Replace(Replace(r.Value, " ", ""), "")
            Next
        End With
    End Sub

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,033

    Re: How to remove all Zero"0" & space from left side

    Here, try this:

    Formula: copy to clipboard
    =SUBSTITUTE(MID(A1,FIND(LEFT(SUBSTITUTE(SUBSTITUTE(A1,CHAR(160),""),0,""),1),A1),255)," ","")
    Never use Merged Cells in Excel

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: How to remove all Zero"0" & space from left side

    Or

    Sub RemoveZeorsAndSpaces()
    Dim c As Range, nEndRw As Long
    
    nEndRw = ActiveSheet.UsedRange.Rows.Count
    Application.ScreenUpdating = False
    
    For Each c In Range("A1:J" & nEndRw)
        If c.Value <> "" Then
            If Left(c.Value, 1) = 0 Then
                c.Value = WorksheetFunction.Substitute(c.Value, " ", "")
                c.NumberFormat = "@"
                Do While Left(c.Value, 1) = 0
                    c.Value = Mid(c.Value, 2, Len(c.Value))
                Loop
            End If
        End If
    Next c
    
    Application.ScreenUpdating = True
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  6. #6
    Forum Contributor
    Join Date
    06-08-2012
    Location
    BD
    MS-Off Ver
    Microsoft Office 2016
    Posts
    640

    Re: How to remove all Zero"0" & space from left side

    Thanks all , both macro & formula are working fine...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1