+ Reply to Thread
Results 1 to 6 of 6

How to order according to comma and bracket?

  1. #1
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    How to order according to comma and bracket?

    The VBA below can order according to comma:
    Please Login or Register  to view this content.
    a,c,e,b,d
    to
    a,b,c,d,e

    How to revise VBA so that it can order within bracket:

    a,c(b,c,a),e,b,d
    to
    a,b,c(a,b,c),d,e

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How to order according to comma and bracket?

    Will the bracket set always stay with the preceding letter; "c" in your example?

    Can there be more than one bracket set?
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to order according to comma and bracket?

    The bracket will be set with any letter or word and more than one bracket set:

    a,c,boy and girl(C-2,c-3,c-1),e,d(2,5,4)
    to
    a,boy and girl(c-1,C-2,c-3),c,d(2,4,5),e

    The aim is to order the words within bracket first;
    and then order according to comma.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: How to order according to comma and bracket?

    Here is one way.

    Please Login or Register  to view this content.
    In your examples you are not doing a case sensitive check. The function has parameters to handle sort order and type of comparison.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: How to order according to comma and bracket?

    Try this code

    Sub SplitAndJoin()

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  6. #6
    Forum Contributor
    Join Date
    09-18-2011
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    375

    Re: How to order according to comma and bracket?

    Thanks Andy Pope and kvsrinivasamurthy, both of yours are works.

    I have revised kvsrinivasamurthy's VBA so that it can apply to any cells (refer '<<<):


    Please Login or Register  to view this content.

+ 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. Sort comma separated string, but in specific order
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-05-2017, 08:53 AM
  2. [SOLVED] VBA to categorize text with comma, semicolon and bracket
    By sroysroy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-23-2015, 10:53 PM
  3. [SOLVED] Custom Order Sort with Comma(,) as Criteria
    By Faridwahidi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2015, 04:37 AM
  4. Replies: 2
    Last Post: 07-18-2014, 03:00 AM
  5. [SOLVED] Order / sort range by number in bracket first then remainder alphabetically.
    By skyping in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2013, 08:14 AM
  6. Help with math bracket calculation order
    By ronlaboa in forum Excel General
    Replies: 3
    Last Post: 12-12-2012, 04:58 AM
  7. Remove String Within the Bracket and also the Bracket
    By seanyeap in forum Excel General
    Replies: 6
    Last Post: 04-23-2010, 10:24 AM

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