+ Reply to Thread
Results 1 to 8 of 8

Ensure strings in column B only appear after the same string in column A

  1. #1
    Registered User
    Join Date
    11-09-2009
    Location
    Shropshire UK
    MS-Off Ver
    Excel 365
    Posts
    38

    Question Ensure strings in column B only appear after the same string in column A

    Hi.

    I have a large spreadsheet (24k rows) of (mostly) clothing products, each product has multiple rows to account for different sizes or colours. This spreadsheet is imported into a database but if it isn't in the correct order the product variations (size-colour) aren't created properly. The attached sample spreadsheet shows how the products are listed using Parent and Child product codes (SKUs). There should be a parent product (with an SKU in column A only) followed directly by any variations (with their own SKU in column A and the SKU of the parent in column B - see example)

    How can I sort the spreadsheet so that the variations (children column B) always directly follow the parent product (column A)?

    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Ensure strings in column B only appear after the same string in column A

    It's not clear to me which is the original data and what are the results you expect.

    Please identify what you start with and manually add the results you expect to see after any sorting has taken place.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-09-2009
    Location
    Shropshire UK
    MS-Off Ver
    Excel 365
    Posts
    38

    Re: Ensure strings in column B only appear after the same string in column A

    Quote Originally Posted by Richard Buttrey View Post
    It's not clear to me which is the original data and what are the results you expect.

    Please identify what you start with and manually add the results you expect to see after any sorting has taken place.
    Sorry, does this make it clearer? (attachment)
    Attached Files Attached Files

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Ensure strings in column B only appear after the same string in column A

    Thanks,

    Leaving aside the number like 22354 for the moment, does it matter if a block like
    B01BL
    B01RE
    B01GR
    B01YE
    B01OR
    B01PI
    S01B

    was sorted in a more natural alphabetical order
    B01BL
    B01GR
    B01OR
    B01PI
    B01RE
    B01YE
    S01B


    and similaly a block like
    S01G
    S01SG
    S01MG
    S01LG
    S01XLG
    S01XXLG

    as
    S01G
    S01LG
    S01MG
    S01SG
    S01XLG
    S01XXLG

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Ensure strings in column B only appear after the same string in column A

    Assuming it's OK to sort the blocks in alphabetical order then add two helper columns to your data

    F2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    G2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    copy both down your list.

    Now select columns A:G and sort on column G ascending.

    Then cut the numbers rows from the top of the list and paste thme at the bottom if it's votal the numbers are shown at the bottom.

  6. #6
    Registered User
    Join Date
    11-09-2009
    Location
    Shropshire UK
    MS-Off Ver
    Excel 365
    Posts
    38

    Re: Ensure strings in column B only appear after the same string in column A

    Thanks Richard. I've just tried this on my 'actual' spreadsheet and it seems to have done the trick! I'm going to import to the db now and see if my broken products get fixed :-)

  7. #7
    Registered User
    Join Date
    11-09-2009
    Location
    Shropshire UK
    MS-Off Ver
    Excel 365
    Posts
    38

    Re: Ensure strings in column B only appear after the same string in column A

    I spoke too soon; it only worked on some of the sheet :-(

  8. #8
    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,460

    Re: Ensure strings in column B only appear after the same string in column A

    That's not enough information for anyone to help further. Under what conditions and in what way did it fail?
    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.

+ 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] Check if other strings exist in column based on range string values
    By jeroenft in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-12-2018, 11:47 AM
  2. [SOLVED] Check if other strings exist in column based on range string values
    By jeroenft in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-12-2018, 07:49 AM
  3. Replies: 4
    Last Post: 08-23-2017, 08:11 AM
  4. [SOLVED] Loop through strings stop when strings change and start looping in the next column...?
    By Prexcel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-18-2013, 03:31 AM
  5. Replies: 2
    Last Post: 06-16-2012, 06:20 PM
  6. [SOLVED] Find various strings and copy the found string in column A of the row it appears in.
    By equanet in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-29-2012, 02:55 PM
  7. If Column A contains one of several strings then change column Bs string
    By Vestax159 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-05-2010, 07:31 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