+ Reply to Thread
Results 1 to 4 of 4

how can i trim entire sheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-06-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    193

    Post how can i trim entire sheet

    how can i trim entire sheet?
    vb macro needed

  2. #2
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: how can i trim entire sheet

    Sub CleanSelection()
        Dim c As Range, rng As Range
        Set rng = Intersect(Selection, Selection.Parent.UsedRange)
        If rng Is Nothing Then
            MsgBox "No cells with values!"
            Exit Sub
        End If
        For Each c In rng
            If Not IsError(c) Then
                c.Value = MEGACLEAN(c)
            End If
        Next c
    End Sub
    
    Function MEGACLEAN(varVal As Variant)
    Dim NewVal As Variant
    If IsMissing(varVal) Then Exit Function
    NewVal = Trim(varVal) 'remove spaces
    NewVal = Application.WorksheetFunction.Clean(NewVal) 'remove most unwanted characters
    NewVal = Application.WorksheetFunction.Substitute(NewVal, Chr(127), "") 'remove ASCII#127
    NewVal = Application.WorksheetFunction.Substitute(NewVal, Chr(160), "") 'remove ASCII#160
    
    MEGACLEAN = NewVal
    End Function
    Hi anilg0001 ,i found this after google
    -If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".

    -Always upload a workbook before start your question
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    +++ If my answer(s) helped you, please add me reputation by click on * +++

  3. #3
    Forum Contributor
    Join Date
    04-06-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    193

    Re: how can i trim entire sheet

    its is not working sir
    means nothing happen
    last blank space in some cell still haveing

  4. #4
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: how can i trim entire sheet

    Can you upload the sample that can't trim. May need see the actual problem. Thanks

+ 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