ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting columns with macros (https://www.excelbanter.com/excel-programming/274325-re-sorting-columns-macros.html)

John Wilson

Sorting columns with macros
 
John,

Coupla' ways (there's more too).
Instead of Range("A10:C30"), try:
Range(Range("A10"), Range("A65536").End(xlUp)).Resize(,3)
if there's an entry in column A for each row that you want included
in the sort or......
Range("A10").CurrentRegion
might work depending on how your data is set up.
You could test the above with a "select" statement to see what
range is actually going to be sorted.

John

John Waupotic wrote:

I'm using the code below to sort the Sheet1 cells in range
of A10 to C30. I'll always want the range to start at
A10, but right and bottom boundaries of the range may
change. Is there a way where you can specify the range
from A10 to "the end" of the worksheet?

Worksheets("Sheet1").Range("A10:C30").Sort _
Key1:=Worksheets("Sheet1").Range("A10")

Thanks,
John



John Waupotic

Sorting columns with macros
 
John,
It works! Thanks very much.

John W.

-----Original Message-----
John,

Coupla' ways (there's more too).
Instead of Range("A10:C30"), try:
Range(Range("A10"), Range("A65536").End(xlUp)).Resize(,3)
if there's an entry in column A for each row that you

want included
in the sort or......
Range("A10").CurrentRegion
might work depending on how your data is set up.
You could test the above with a "select" statement to see

what
range is actually going to be sorted.

John

John Waupotic wrote:

I'm using the code below to sort the Sheet1 cells in

range
of A10 to C30. I'll always want the range to start at
A10, but right and bottom boundaries of the range may
change. Is there a way where you can specify the range
from A10 to "the end" of the worksheet?

Worksheets("Sheet1").Range("A10:C30").Sort _
Key1:=Worksheets("Sheet1").Range("A10")

Thanks,
John


.



All times are GMT +1. The time now is 05:29 PM.

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