+ Reply to Thread
Results 1 to 5 of 5

Automatic Sorting Macro for Text Values

  1. #1
    Registered User
    Join Date
    04-26-2021
    Location
    Dallas, Texas
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Question Automatic Sorting Macro for Text Values

    Hey all, newbie at Excel Macros here. I've looked around on the internet and can't seem to find a solution, so I'll post it here and hopefully get some answers.

    I am an inventory associate at a wholesale shirt store, and I want to use macros to automatically sort rows of shirt info so I can check if we have it in stock or not.
    Attached is a 20 row sample of shirts with some information.
    Column A shows the status of the shirt (N for new, P for preorder, C for check if it is available, D for discontinued, and I for in-stock which is the default normal value).
    Column B shows the date that either the Preorder shirts should arrive by, or the date that the New shirt was posted.
    Column C is the name of the shirt, referred to as Style #.
    Columns D through G are for seeing if the designs (called transfers) and/or the shirts with the designs are uploaded to the website. These can also be ignored for sorting.
    The data is in the range of A2:G20.

    What I would like to do with macros is the following:
    1. Automatically sort the rows so that items with status C are moved to the top (row 2), followed by status P, followed by status N, followed by statuses I and D, which don't need to be sorted.
    2. Automatically change P to C when the date in Column B passes today's date (in cell J3), which is 4/26/2021. I would set the formula to =TODAY() but I need the correct date for examples in the table.
    3. Automatically change N to I and remove the date from Column B when this date is 30 days past today's date. An example would be Row 19, which was New 30 days ago from today (4/26).
    4. Automatically alphabetically sort each section of rows using the names. The sections are based on the statuses: P, C, N, and D/I (which are mixed together). Within each section, sort the rows alphabetically using Column C.

    It is important that these things be automatic (or at least at the push of a button like F5 or something) because our stock has 2000+ items.
    Obviously any code I can copy and paste would be extremely helpful, but any sort of guidance or advice I can get would also be very appreciated!
    Attached Files Attached Files
    Last edited by BlueStylus; 04-26-2021 at 07:11 PM. Reason: Changed some unclear things

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: Automatic Sorting Macro for Text Values


    Hey,

    as point 4 is unclear, well elaborate it ! (Sort each section ok but what is the key column ?!)
    Or just post an attachment of the expected result according to your initial attachment …

  3. #3
    Registered User
    Join Date
    04-26-2021
    Location
    Dallas, Texas
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Automatic Sorting Macro for Text Values

    Quote Originally Posted by Marc L View Post

    Hey,

    as point 4 is unclear, well elaborate it ! (Sort each section ok but what is the key column ?!)
    Or just post an attachment of the expected result according to your initial attachment …

    Hey Marc,

    My apologies! I did not mean to be unclear on point 4. I will edit the original post to be clearer.

    What I meant is that I would like to alphabetize within each section. Here is an example of what I mean:

    Row number | Status | Style #
    1 | C | BC APPLES
    2 | C | BC ZEBRAS
    3 | P | BC BASEBALL
    4 | P | BC COFFEE
    5 | N | BC AWESOME
    6 | N | BC DOG MOM
    7 | I | BC MAGICAL
    8 | I | BC NIGHT SKY
    9 | D | BC OH MY GOD
    10 | I | BC PREPARE
    11 | D | CH AMAZING
    12 | I | CH BASEBALL

    As you can see, within each section of status C, P, N, and I/D, the items are sorted by alphabetical style number. I hope this makes it clear what I want to do! Thank you!
    Last edited by BlueStylus; 04-26-2021 at 06:09 PM.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this …


    According to your attachment a VBA beginner starter in the text file
    joined below as I can't post the code 'cause of this website dumb firewall …

    You must paste this VBA demonstration to the Sheet1 worksheet module

    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-26-2021
    Location
    Dallas, Texas
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Try this …

    Quote Originally Posted by Marc L View Post

    According to your attachment a VBA beginner starter in the text file
    joined below as I can't post the code 'cause of this website dumb firewall …

    You must paste this VBA demonstration to the Sheet1 worksheet module

    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !
    Worked exactly as I wanted! Thank you very much, I added reputation for you! :D

+ 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. [SOLVED] Automatic partial formatting of text between certain values
    By schjacob in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-07-2019, 02:56 AM
  2. Sorting Ranges with Text Values and Number Values using Formula
    By oudavid1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-27-2017, 03:05 PM
  3. Automatic sorting of values
    By PDAUGHE1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-02-2015, 08:01 PM
  4. [SOLVED] Is an automatic Sorting Macro possible?
    By ElmerFud in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-01-2014, 04:08 PM
  5. Automatic Sorting macro codes for Excel 2011
    By CMoore12 in forum Excel General
    Replies: 1
    Last Post: 07-18-2012, 03:46 AM
  6. Replies: 2
    Last Post: 06-17-2011, 03:00 PM
  7. Automatic Macro Sorting of cells
    By liampog in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-24-2010, 03:20 PM

Tags for this Thread

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