ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   help: sorting rows by lesser value of two columns (https://www.excelbanter.com/excel-programming/430503-help-sorting-rows-lesser-value-two-columns.html)

[email protected]

help: sorting rows by lesser value of two columns
 
I'd like a VB script method of sorting that uses two columns (both
contain dates/times). I want to sort the entire row in ascending
order by the lesser value of the two columns.

Example:

column A Column B

Row 1: 1
2 <--lesser value is 1
Row 2: 2
2 <--Lesser value is 2
Row 3: 4
4 <--Lesser value is 4
Row 4: 5
3 <--Lesser value is 3

BECOMES:

column A Column B

Row 1: 1 2
Row 2: 2 2
Row 3: 5 3
Row 4: 4 4

I could do it using a third column, but would prefer something more
elegant using a temproray array. Any help would be appreciated. My
problem is this: I can create a "sort-order array", but I don't know
how to shuffle the rows according to the sequence of the array.

Thanks in advance,

Todd

Jabberwocky

help: sorting rows by lesser value of two columns
 
sorry that wrapped funny. Perhaps this will be clearer:
Example:

* * * * * column A * * Column B

Row 1: * 1 2 ** * *<--lesser value is 1
Row 2: * 2 2* * * *<--Lesser value is 2
Row 3: * 4 4 * * *<--Lesser value is 4
Row 4: * 5 3 * * *<--Lesser value is 3

BECOMES:

* * * * * column A * * Column B

Row 1: * 1 * * * * * * * * 2
Row 2: * 2 * * * * * * * * 2
Row 3: * 5 * * * * * * * * 3
Row 4: * 4 * * * * * * * * 4



All times are GMT +1. The time now is 09:55 AM.

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