ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sort function? (https://www.excelbanter.com/excel-discussion-misc-queries/170393-sort-function.html)

Phil

Sort function?
 
Excel does not appear to have a sort function.:-(

I can use the Sort option from the Data menu, but this has two major
problems:
1) The sort is only done once. If the data change, they don't stay
sorted.
2) If the data are calculated using a formula, sort doesn't work.

Any suggestions on the best way around this?
What I'm actually trying to do is create a workbook with various
calculations in. I just want people to be able to put their own data in the
first column, and have another column somewhere display the results of the
calculations (which involve sorting the data along the way).

If there was a sort function, this would be easy. For example I could put a
formula in cells B2:B5 something like =SORT(A2:A5). I expect I could write
such a function in VBA, but if anyone has any better ideas, or some code
that's already been written that would be very much appreciated.

Phil.



Phil

Sort function?
 
I think I've found it. This seems to do the trick:

=SMALL(A2:A5,ROW()-1)


"Phil" <N/A wrote in message ...
Excel does not appear to have a sort function.:-(

I can use the Sort option from the Data menu, but this has two major
problems:
1) The sort is only done once. If the data change, they don't stay
sorted.
2) If the data are calculated using a formula, sort doesn't work.

Any suggestions on the best way around this?
What I'm actually trying to do is create a workbook with various
calculations in. I just want people to be able to put their own data in
the first column, and have another column somewhere display the results of
the calculations (which involve sorting the data along the way).

If there was a sort function, this would be easy. For example I could put
a formula in cells B2:B5 something like =SORT(A2:A5). I expect I could
write such a function in VBA, but if anyone has any better ideas, or some
code that's already been written that would be very much appreciated.

Phil.




rdwj

Sort function?
 
Phil,
have a look at the RANK formula. Together with MATCH and Offset you can
create a function based sort. Offset(Match(Rank()))

rdwj


"Phil" wrote:

I think I've found it. This seems to do the trick:

=SMALL(A2:A5,ROW()-1)


"Phil" <N/A wrote in message ...
Excel does not appear to have a sort function.:-(

I can use the Sort option from the Data menu, but this has two major
problems:
1) The sort is only done once. If the data change, they don't stay
sorted.
2) If the data are calculated using a formula, sort doesn't work.

Any suggestions on the best way around this?
What I'm actually trying to do is create a workbook with various
calculations in. I just want people to be able to put their own data in
the first column, and have another column somewhere display the results of
the calculations (which involve sorting the data along the way).

If there was a sort function, this would be easy. For example I could put
a formula in cells B2:B5 something like =SORT(A2:A5). I expect I could
write such a function in VBA, but if anyone has any better ideas, or some
code that's already been written that would be very much appreciated.

Phil.






All times are GMT +1. The time now is 11:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com