+ Reply to Thread
Results 1 to 11 of 11

Trim first word in cell

  1. #1
    Registered User
    Join Date
    06-20-2013
    Location
    Bratislava
    MS-Off Ver
    MS EXCEL 2021
    Posts
    90

    Trim first word in cell

    Hi gentlemen,

    I would like to ask,

    If i have column F, each row has 1 code in cell (different length), but sometimes after this code is many spaces and some other words or codes...

    How to left only first world in cell by macro ?

    thanks
    Last edited by xbr088; 06-24-2013 at 04:10 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Trim first word in cell

    xbr088,

    Something like this should work for you:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Trim first word in cell

    What separates the code from the rest of the cell contents?

    Is it a space?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    06-20-2013
    Location
    Bratislava
    MS-Off Ver
    MS EXCEL 2021
    Posts
    90

    Re: Trim first word in cell

    yes, spaces are separating first word from other words in cell ( different amount of spaces)

    I am going to try upper solution. moment

  5. #5
    Registered User
    Join Date
    06-20-2013
    Location
    Bratislava
    MS-Off Ver
    MS EXCEL 2021
    Posts
    90

    Re: Trim first word in cell

    Tigeravatar,

    yes, this i need, but your formula only shows me first word in cell in popup window.

    But how to left in whole column F only first word in row's cell ?

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Trim first word in cell

    The code I provided is a sample to show you how to get what you requested. You need to apply it to your current code. I imagine you have a loop setup already that goes through column F. If you don't, here is some more example code:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-20-2013
    Location
    Bratislava
    MS-Off Ver
    MS EXCEL 2021
    Posts
    90

    Re: Trim first word in cell

    Hmm, small confusing. i tried both of your codes. and both made same. Extract first word and shows me in popup window. That's great, but after i close this popup, everything stay same, nothing is trimmed. Where i made fault ?

    Sorry for my dummy question But i need only keep first word in all row's cells in F column, and all others to delete (means others spaces, words)
    Last edited by xbr088; 06-24-2013 at 03:53 PM.

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Trim first word in cell

    Oh, you want to replace what is in column F with the codes that get retrieved, you can do that like so:
    Please Login or Register  to view this content.

  9. #9
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Trim first word in cell

    Here's an alternate way to do the same thing, but it would be harder to edit and is probably not very easy to follow/understand:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-20-2013
    Location
    Bratislava
    MS-Off Ver
    MS EXCEL 2021
    Posts
    90

    Re: Trim first word in cell

    Ou thats it :-)

    Simple question, but so difficult macro code. But anyhow is usefull. solved

    THANX

  11. #11
    Registered User
    Join Date
    06-20-2013
    Location
    Bratislava
    MS-Off Ver
    MS EXCEL 2021
    Posts
    90

    Re: Trim first word in cell

    Both solutions works, i will use shorter. 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