sorting

H

Hitch1961

I have a spreadsheet that has three lines of data per one subject. I need to
sort in alphabetical order the first line making sure the 2nd and 3rd stay
with the first line, same for lines 4-6, 7-9, ect...
 
N

ND Pard

In an empty column, in your 1st row of data (excluding the row with column
headings, if any), begins in row 5, enter the formula:

=ROUNDUP((ROW()-(5-1))/3,0)

and copy it down.

If the data begins in row 8, substitute an 8 in place of the 5 in the above
formula.

Convert this column of formulas to values via a column
Copy and Paste Special as 'values'.

Now you can sort using the new column as the primary key and the column that
is to be in alpabetical order as the secondary key.

Good Luck.
In an empty column
 
N

ND Pard

I misunderstood what you were looking for in my first response.
Let me try again.

First, insert four (4) columns to the left of your data.
For purposes of this example, these new columns will be columns A, B, C and D.
This example will also assume your first row of data (excluding Column
Headers, if any) is row 5.

In cell A5 enter the formula:
=ROUNDUP((ROW()-(5-1))/3,0)

(Note: If the first row was row 8, substitue an 8 instead of the 5 in the
above formula. Remaining formulas need to be adjusted as appropriate also.)

In cell B5 enter the formula:
=IF(EXACT(A4,A5),B4+0.1,A5+0.1)

In cell C5 enter the formula:
=RIGHT(B5,1)

In cell D5 enter the formula:
=IF(EXACT(C4,C5),D4+1,1)

Convert the formulas in columns A, B and C to values via a Copy and Paste
Special 'values'.
NOTE: do NOT convert column D to values at this time.

Sort all of the data, including the new columns A thru D, using column C as
the Primary Key and column B as the Secondary Key.

Now resort the data using ONLY rows with a 1 in column C, using your
alphabetical column (whatever that might be) as the Primary Key..
(This assumes the alphabetical order is determined by a column with a 1 in
column C.)

In column D, starting with the first row that has a 2 in column C, enter the
formula:
=VLOOKUP(A19,$A$5:$col$row,4,FALSE)
In the above formula, substitute the Last column of data for "col" and the
last row with a 1 in column C for "row".
For example, if your last column of Data is column H and the last row with a
1 in column c is 80, then the formula would be:
=VLOOKUP(A19,$A$5:$H$80,4,FALSE)

Copy this formula down (not up) to the last row of data.

Convert all of the formulas in column D to values.

Finally sort all of the data, including columns A thru D, using column D as
the Primary Key and column B as the Secondary Key.

Your data should be in the desired order.

Good Luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Pivot Table sorting 1
Sorting Groups of Rows 1
Sorting 1
wrap text from one column to the next 1
Sorting Multiple Columns - 2
VBA- Excel Programming:- 0
Sorting in Excel 1
Alpha sorting (with a twist...?) 3

Top