+ Reply to Thread
Results 1 to 7 of 7

Removing the first space only

  1. #1
    Registered User
    Join Date
    03-23-2012
    Location
    toronto
    MS-Off Ver
    Excel 2007
    Posts
    3

    Removing the first space only

    Hi,

    I have an excel sheet where I need to remove the first space of the string ONLY. My information looks like this:

    Column Column Column Column
    Sean Test The Testing Company Director and CEO

    There is a space between the cell wall and the beginning of the text string. I've used the trim function, however it removed all the spaces and made my sheet look like this:

    Sean Test TheTestingCompany DirectorandCEO

    Is there anyway just to remove the first space of the string?

    thanks!

  2. #2
    Valued Forum Contributor
    Join Date
    03-16-2012
    Location
    Aarhus, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    992

    Re: Removing the first space only

    =mid(ref_to_text;2;256)
    Sincerely
    S?ren Larsen

    "Give a man a fish, and you'll feed him for a day. Give a man a fishing rod, and he'll steal your yacht!"

  3. #3
    Registered User
    Join Date
    03-23-2012
    Location
    toronto
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Removing the first space only

    Great, That worked aweosme! Thank you ! Do you know how I can get my text that looks like TheTrainingCompany to look like The Training Company again? The original file was lost

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Removing the first space only

    trim doesn't remove all spaces ,how exactly are you using it? post a sample worksheet.
    you can get rid of leading spaces in a column by using text to columns /fixed width/remove any break lines/click finish
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Registered User
    Join Date
    03-23-2012
    Location
    toronto
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Removing the first space only

    Also a great suggestion that works ! thanks!

    any advise for fixing the mistake?

    I'm not sure how it was used to be honest, my colleague used it then sent the sheet to me to see if I could correct it I guess she deleted the original which is why I don't know how to fix the TheTestingCompany since all the other merged strings are different lengths (ex. TheTestingCompany , ThreeTest ) so I can't use text to columns

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Removing the first space only

    that's going to be difficult! there are no functions that will do that in excel ,code splitting on caps can be done
    but i find it easier just to start again
    copy paste into word as unformatted text
    then find replace make sure using wild cards option is selected
    find
    [A-Z]
    replace with
    ^s^&
    that will put your spaces back then copy back into excel

  7. #7
    Forum Contributor
    Join Date
    09-23-2008
    Location
    Mexico
    Posts
    200

    Re: Removing the first space only

    Try this:
    http://www.mrexcel.com/forum/showthr...56#post2095356

    pgc01

    Sub CamelCase()
    Dim rC As Range

    With CreateObject("VBScript.RegExp")
    .Pattern = "([a-z])([A-Z])"
    .Global = True
    For Each rC In Selection
    rC.Parse "[" & .Replace(rC, "$1][$2") & "]", rC.Offset(, 2)
    Next rC
    End With
    End Sub

+ 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