+ Reply to Thread
Results 1 to 16 of 16

rearrange words in a single cell by noun, verb, etc. VBA

  1. #1
    Registered User
    Join Date
    03-24-2017
    Location
    richmond, va
    MS-Off Ver
    2010
    Posts
    8

    rearrange words in a single cell by noun, verb, etc. VBA

    Is there anyway to easily rearrange words in a single cell with say a drag and drop option or something easier than cut/paste?

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: rearrange words in a single cell

    In a random fashion or otherwise? I think you'll need to look at VBA for this - shall I move the thread to the right place for you?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    03-24-2017
    Location
    richmond, va
    MS-Off Ver
    2010
    Posts
    8

    Re: rearrange words in a single cell

    Sure.
    Like this:
    Original Final
    BURTBEE: BRIGHTENING EVEN SKIN TONE MOISTURIZING CREAM BURTBEE: MOISTURIZING CREAM BRIGHTENING EVEN SKIN TONE
    BURTBEE: GUD ORANGE PETALOOZA NATURAL CLEANSING WIPES BURTBEE: CLEANSING WIPES GUD ORANGE PETALOOZA NATURAL
    BURTBEE: SENSITIVE NIGHT CREAM BURTBEE: NIGHT CREAM SENSITIVE
    CLIF: BUILDER'S VANILLA ALMOND PROTEIN BAR 6CT CLIF: PROTEIN BAR BUILDER'S VANILLA ALMOND 6CT
    CLIF: COCONUT ALMOND CHOCOLATE WHEY PROTEIN BARS 5CT CLIF: PROTEIN BARS WHEY COCONUT ALMOND CHOCOLATE 5CT
    CLIF: PEANUT BUTTER & CHOCOLATE WHEY PROTEIN BARS 5CT CLIF: PROTEIN BARS WHEY PEANUT BUTTER & CHOCOLATE 5CT

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: rearrange words in a single cell

    No, sorry - you've lost me completely ...

  5. #5
    Registered User
    Join Date
    03-24-2017
    Location
    richmond, va
    MS-Off Ver
    2010
    Posts
    8
    Quote Originally Posted by AliGW View Post
    No, sorry - you've lost me completely ...
    Trying in MS Word
    Thanks

  6. #6
    Registered User
    Join Date
    03-24-2017
    Location
    richmond, va
    MS-Off Ver
    2010
    Posts
    8

    Re: rearrange words in a single cell

    Like this...
    Attached Files Attached Files

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: rearrange words in a single cell

    I guess from your sample that the order matters?

  8. #8
    Registered User
    Join Date
    03-24-2017
    Location
    richmond, va
    MS-Off Ver
    2010
    Posts
    8

    Re: rearrange words in a single cell

    Yes it's supposed to be "BRAND: NOUN VERBS ETC."

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: rearrange words in a single cell

    Excel is not natively clever enough to distinguish between parts of speech, so building a formula to tell it how would be impossible. I think even using VBA will be a monumental task, but I'll move you to that section of the forum and amend the thread title for you to see if anyone can help.

  10. #10
    Registered User
    Join Date
    03-24-2017
    Location
    richmond, va
    MS-Off Ver
    2010
    Posts
    8

    Re: rearrange words in a single cell

    I believe just copying that column to Word and editing there "drag and drop" would prob be the simplest way to go....thank you though.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: rearrange words in a single cell by noun, verb, etc. VBA

    OK - well, if you decide you don't want any further help here, then please mark the thread as solved. Thanks!

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: rearrange words in a single cell by noun, verb, etc. VBA

    I would think this is not just monumental, it would be impossible. Some of the words could be either nouns or verbs depending on the context. Others are "connected" by an ampersand (&) and so should be treated as a single word (noun).

    How you would go from this "CLIF: PEANUT BUTTER & CHOCOLATE WHEY PROTEIN BARS 5CT" to this "CLIF: PROTEIN BARS WHEY PEANUT BUTTER & CHOCOLATE 5CT" is anyone's guess.
    Last edited by TMS; 04-05-2017 at 12:27 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,853

    Re: rearrange words in a single cell by noun, verb, etc. VBA

    I thought so, Trevor, but thanks for confirming.

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,446

    Re: rearrange words in a single cell by noun, verb, etc. VBA

    Yes; I wish that I could offer some encouragent but even something as simple as "tone" could be taken either way. And, according to Dictionary.com, "night" could be a noun, an adjective or part of an idiom, for example, "night and day".

    I realise that the context is somewhat limited but my order of preference could be different to anyone else's ... and defining a set of rules, I suspect is beyond the capability of Excel.

  15. #15
    Registered User
    Join Date
    12-17-2016
    Location
    South Wales
    MS-Off Ver
    Excel 2007, 2016
    Posts
    68

    Re: rearrange words in a single cell by noun, verb, etc. VBA

    I think its down to whether you can identify a common pattern/set of "rules". In your example, all but the last two examples seem to meet the following set of rules:
    - The first word, including the colon, remains the first word.
    - If the last word starts with a number, it stays at the end.
    - The last two words, ignoring one starting with a number, go to the second position.
    However in the last two examples, the position of the word WHEY doesn't meet those rules!

    So ... if you can define a single set of rules, no matter how complex, it can be done with VBA. But if it requires human knowledge/interpretation, then it can't!

    I suppose another option is if you create rules that would work for most, it would give you less results to manually amend... ?

  16. #16
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: rearrange words in a single cell by noun, verb, etc. VBA

    not exactly what the OP asked for but a little tool that could help
    since there is no "computerised" logic to rearrange the words

    so the next best thing i can think of is specify the order you want of the words and let the computer combine it based on this
    so the attached UDF takes this idea

    first you would need to split the original cell by using text to column and using Space delimiter
    the rest is somewhat self explanatory i hope
    if there was a much longer list, it may be a little faster than the OP doing in word with drag and drop ?
    at least certainly it would be faster to fix any errors in the arrangement of the words
    Attached Files Attached Files
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 01-14-2017, 10:57 AM
  2. Separating words in a single cell
    By ibere in forum Excel General
    Replies: 12
    Last Post: 01-24-2012, 12:56 PM
  3. summing up varying words in a single cell
    By JordanGoodchild in forum Excel General
    Replies: 1
    Last Post: 07-21-2010, 11:58 PM
  4. Highlight cell with many words, with duplicates from row with single words.
    By Meows in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2010, 08:27 PM
  5. Rearrange order of words
    By NPM2 in forum Excel General
    Replies: 3
    Last Post: 11-22-2009, 06:58 PM
  6. Rearrange words
    By wakegirl814 in forum Excel General
    Replies: 13
    Last Post: 11-18-2009, 03:31 PM
  7. Functions and words in a single cell
    By [email protected] in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-17-2008, 05:19 PM

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