Thread: Sort by range
View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
FrankM FrankM is offline
external usenet poster
 
Posts: 45
Default Sort by range

Thank you so much for your assistance. I am sorry if it seems a bit confusing
what I'm trying to accomplish.

Column A has the values in the cells, "a", "b", "c", "d" and so forth. The
Macro I have to sort the information starts sorting this column and puts all
the "a"s together, all the "b"s together and so forth. I then have data in
columns B through AC (Names, IDs, Contact Information and other data).
Columns I, J and K all have dates (I'm sorting the records base on these
values). I hope that helps.



I have done my best to answer the questions you asked.



What column contains the sort direction indicator?

I initial sort based on column A, this puts all the groups together. Then I
have subsequent sorts on columns J and K

Is that code on every record in the group?

Yes

What column contains the group indicator?

Column A

Does your data need to be sorted by this indicator before it starts (so all category x's are together to start)????

Yes and that is part of the initial sort (by column A to put each group
together)

What are the columns you want sorted by? Which column uses the direction indicator?

I would like to sort first by column A, this puts all the groups together.
Then I want to sort by columns J and K. I would like to add an additional
sort after these that selects any row that the value of the cell in column A
is "d" and sort that selection by column I (ascending).

Are the other columns always sorted ascending (or descending)?

Yes

What is the top row of the first group?

The entries start at row 2, row 1 is a header row. I start my sorts based on
row 2.

Can I use the category indicator column to find the last row of the data?

Yes. The last row will always have the value "a" in the cell in column A.






"Dave Peterson" wrote:

ps.

What is the top row of the first group?
Can I use the category indicator column to find the last row of the data?

Dave Peterson wrote:

I'm gonna simplify the problem slightly.

Say you have data in A1:c10 that looks like this:

a x $C$1
d y $C$2
d y $C$3
a z $C$4
a z $C$5
a z $C$6
d w $C$7
d w $C$8
d w $C$9
d w $C$10

Column B is the category indicator and column A is the sort direction indicator.

You'd want row 1 (the only a in that "group") sorted ascending.
You'd want rows 2-3 sorted descending
you'd want rows 4-6 sorted ascending
you'd want rows 7-10 sorted descending

So column B serves as a "group" indicator as well as the sorting order
direction.

If that's kind of what you mean, then (just to verify)...

What column contains the sort direction indicator? Is that code on every record
in the group?

What column contains the group indicator?

Does your data need to be sorted by this indicator before it starts (so all
category x's are together to start)????

What are the columns you want sorted by? Which column uses the direction
indicator? Are the other columns always sorted ascending (or descending)?

FrankM wrote:

"Dave Peterson" wrote:

I think it's time to describe what you want again.

The code you posted sorted A1:U700. I'm not sure how looking at multiple cells
in column A would determine what range to sort -- or even if it does.


Thank you so much for your response. I will try to explain a little better
what Iâm working on.

I have a spreadsheet that currently has data in columns A to AC; it use to
have data in just columns A to U. It looks like Iâm going to have to update
my current Macro. The data is currently in rows 1 to 269 but everyday another
couple of records are entered.

Column A is an indication of the category. Everything starts out in Category
âœa❠and then moves to category âœbâ, âœcâ, âœd❠and so forth. Different items
move at different paces so one entry may move through each category faster
than another entry. It is all part of the process.

To keep each category together I would sort the spreadsheet on a regular
basis. Then I decided it would be better to just create a Macro and click a
button to do the sort for me.

I then needed to have different categories sorted differently so I added to
my sort the columns K and J.

What I am now trying to do is enter an additional sort for the items in
category âœdâ, to be sorted ascending by the value in column I. The number of
rows with âœd❠in the cell in column A will vary; sometimes there will be five
of them sometimes there may be six or seven. The rows that this applies to
will also change; âœd❠may be in column A rows 239, 240, 241 and 242 one day
but rows 247, 248 and 249 the next.

I want to come up with a way to select all the rows that have the value âœdâ
in the cell of column A and sort that selection ascending by the value in
column I.

I understand the original Range may have been confusing. I think when I
originally created this Macro I just inserted a Range larger than I thought I
would need. It was fast and dirty but it accomplished what it needed to at
the time.

I would love to hear any thoughts or suggestions. Thank you.


--

Dave Peterson


--

Dave Peterson
.