+ Reply to Thread
Results 1 to 5 of 5

VB code to Group by certain text in cells

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    4,434

    VB code to Group by certain text in cells

    Hello:

    Please refer to attached file.
    I need VB Code to filter column A so that all sizes (end of item Name) are grouped together

    Let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: VB code to Group by certain text in cells

    Can not you use the auxiliary/helping column for these capacities, measures ?
    Last edited by mjr veverka; 05-21-2019 at 03:48 PM.

  3. #3
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VB code to Group by certain text in cells

    Hi Riz

    Perhaps this...Adapted from jindon's code...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VB code to Group by certain text in cells

    Hello Riz,

    As with any sorting procedure, there are always some exceptions to the rules. Here are the three I found in your workbook: JIM BEAM LTR, JIM BEAM DISTILLER'S CUT 750, and JIM BEAM APPLE. The remaining data can be sorted in ascending order (case is ignored) like this: 50ml, 100ml, 200ml, 375ml, 750ml, 1000ml, 1L, 1.75L . A normal text sort will not produce these results, smallest to largest. To achieve a sort like this requires a Custom Sort list.

    The attached workbook contains two macros. The first macro checks if the Custom Sort List exists and creates it if it does not exist and then returns the position of the new sort list in the Sort Lists used by Excel. The second macro removes the size information using Regular Expressions, places this in a helper column (the column on the right side the original list) and then sorts the data using the Custom Sort. There is a button on "Sheet1" to run the macros.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: VB code to Group by certain text in cells

    Perhaps this amended code could also work...Not sure what desired output should be...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 05-23-2019 at 03:58 AM.

+ 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. If a group of cells in the same column contain same text.......
    By btrav in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-01-2018, 11:37 PM
  2. [SOLVED] HELP - Need code to add a border and title to a group of cell based on one cells specifics
    By keithorourke in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-19-2016, 03:52 PM
  3. How to auto group code/text imported into excel?
    By godfather927 in forum Excel General
    Replies: 1
    Last Post: 10-21-2013, 01:24 PM
  4. [SOLVED] Record if there is any text in a group of cells
    By u5e10 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-14-2012, 11:43 AM
  5. Replies: 11
    Last Post: 05-06-2009, 06:08 AM
  6. Extracting text from a group of cells
    By hoopz in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-31-2006, 05:35 PM
  7. [SOLVED] Formatting a group of cells for text
    By Lee in forum Excel General
    Replies: 4
    Last Post: 02-25-2006, 02:40 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