+ Reply to Thread
Results 1 to 9 of 9

List out words from sentences

  1. #1
    Registered User
    Join Date
    09-24-2007
    Posts
    9

    List out words from sentences

    Hi I have a sentences in cloumn A like below ... I have tried to list out each word from sentence into another coulumn word by word using a macro like this.
    Input file columna A
    A1: Good Morning Everyone
    A2: Good Evening Everyone
    A3: Good Night Everyone

    Output to next column B should be

    B1: Good
    B2: Morning
    B3: Everyone
    B4: Good
    B5: Evening
    B6: Everyone
    B7:Good
    B8: Night
    B9: Everyone

    The below macro I used is working for only A1. someone could you please advise how can I implement this for column A range from A1 to upto A400 ?

    Please Login or Register  to view this content.
    Someone please help me...Thank you for your help in advance.
    Last edited by ap_naveen; 10-21-2010 at 05:10 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: List out words from sentences

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: List out words from sentences

    Many approaches in truth, one might be:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: List out words from sentences

    a 2-liner:
    Please Login or Register  to view this content.



  5. #5
    Registered User
    Join Date
    09-24-2007
    Posts
    9

    Re: List out words from sentences

    This worked for me...thank you

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: List out words from sentences

    @snb - assuming no interspersed blanks and min. of 2 entries of course

    Out of curiosity if the shortness of code is critical then why: Cells(1,1) ?

    FWIW, based on above:

    Please Login or Register  to view this content.
    Not that I would necessarily use it of course

    P.S. Before interpreted otherwise I'm not saying this code isn't the better alternative (declarations aside but we won't go there)...
    Last edited by DonkeyOte; 10-21-2010 at 05:56 AM.

  7. #7
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: List out words from sentences

    @DonkeyOte,

    Good points.
    the minimal 2 entries is a sine qua non for the question in the first place.
    I didn't spot adjacent spaces in the example posted but if robustness is critical see below.

    Shortness of code isn't important nor critical, but parsimony can be a personal preference ( and in math it's a desirable/necessary criterion). You drew my attention (thanks for that ) to further improving the code:

    Please Login or Register  to view this content.

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: List out words from sentences

    What I was referring to was a scenario such as A1:A4:

    apples and pears

    dog and bone
    trouble and strife
    the code in my prior post (adapted from yours) would retrieve successfully I believe.

    I won't pretend I fully understand what your prior code is meant to be doing but it does not cater for the above scenario [admittedly an unspecified scenario]

    I pointed this out as a "just in case" - nothing more.

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: List out words from sentences

    @DonkeyOte,

    Now I see what you meant (interspersed blanks: blank cells instead of spaces )

    I tried to solve it this way

    Please Login or Register  to view this content.
    But in the meanwhile you posted an alternative I not quite dislike.
    I never made use of application.trim because my VBA-background lies in Word where there's no such thing as application.trim. The code you proposed is much faster than the use of evaluate. So I stick to the coproduction you posted earlier (with a minor adaptation; cells(6) instead of cells(6,1) )
    Last edited by snb; 10-21-2010 at 07:09 AM.

+ 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