Results 1 to 2 of 2
Thread: Row Sorting (2000)
2002-06-27, 19:58 #1
- Join Date
- Jun 2002
- Thanked 0 Times in 0 Posts
Row Sorting (2000)
In WOODY's OFFICE WATCH Vol 5 No 19 from 27 April 2000,
Section 5. READER CHALLENGE - ROW SORTING RESPONSES has a great solution to a row sorting challenge. However, I need to slightly modify it and would like your help!
Here's the deal:
I have a worksheet almost identical to the one described in the reader challenge. However, I have additional columns of data after the sort range. In the reader challange the sort range was defined as:
Selection.Sort Key1:=Range(ActiveCell.Address) This line tells Excel to begin with the active cell and
select all of the cells to the end of the row of numbers (similar to using the Shift+End+Right Arrow keyboard shortcut).
Because I have additional columns after the sort range, This won't work for me. My worksheet has 10 rows A-J. I need to only sort rows E-H, Left to Right in ascending order.
Thanks in advance!
2002-06-28, 06:01 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 Posts
Re: Row Sorting (2000)
The select part in the original macro is
The .End(xlToRight) extends the selection as far as possible.
In your case, you want to select a fixed number of cells. To do this, use
<pre>Range(ActiveCell, ActiveCell.Offset(0, 3)).Select</pre>
The .Offset(0, 3) refers to the cell in the same row as ActiveCell, but 3 columns to the right. If you wanted to sort 7 columns, you would use .Offset(0, 6).
Make sure cell E2 is selected when you start the macro.