Search code examples
excelsortingexcel-formulaworksheet-functionvba

Sort a list by groups of varying number of rows


I've imported the results of a broken link search in to Excel and I now need to sort the results based on the error code. I can't get my head around how to do this because the error code is in the row below the URL and not in a column next to it. Also, some URLs take up more than one row.

Here is a screenshot of part of the spreadsheet:

results in excel

How would I go about grouping all results with error 404 together?


Solution

  • Insert a column to the left of A and fill in with a sequence of numbers (1, 2, 3, ...). Now sort by column B. Select all the error code entries and drag them to column c (or some other empty column). Resort the sheet by the sequence of numbers in column A. Now with everything ordered and the error codes is a separate column (C), you can right-click on C1, and select shift cells up. Column A can be deleted, and you can sort by the URL's (although it looks like you clean up the text a bit).