#1
  1. Mmmm...Donkey punch...
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2004
    Location
    All up in your grill
    Posts
    981
    Rep Power
    43

    Remove double spaces


    I have an Excel file that I imported into an Access database. A lot of the field entries have been found to have " " (double spaces) or extra spaces after the last character. This is causing numerous fields to not group correctly.

    Can someone provide me with a VBA script that will remove all double spaces or spaces after the last intended character?
  2. #2
  3. Type Cast Exception
    Devshed Supreme Being (6500+ posts)

    Join Date
    Apr 2004
    Location
    OAKLAND CA | Adam's Point (Fairyland)
    Posts
    14,954
    Rep Power
    8617
    Code:
    Function CleanSpace(ByVal strIn As String) As String
      ' // Remove leading or trailing spaces
        strIn = Trim(strIn)
      ' // Replace all double space pairings with single spaces
        Do While InStr(strIn, "  ")
            strIn = Replace(strIn, "  ", " ")
        Loop
      ' // Return the result
        CleanSpace = strIn
    End Function

    Comments on this post

    • Cheesefood agrees : Thanks, Media!
    medialint.com

    “Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss

IMN logo majestic logo threadwatch logo seochat tools logo