ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sort on 3 columns when number of rows vary daily (https://www.excelbanter.com/excel-programming/447984-sort-3-columns-when-number-rows-vary-daily.html)

Tonso

Sort on 3 columns when number of rows vary daily
 
I daily download data to an XL2007 workbook. The data has 30 columns. It needs to be sorted, and I use Data, Sort to sort by 1. Date, Values, A to Z, 2. Then by Type, Values, Z to A, and 3. Then by Area, Values, Smallest to Largest. This works fine. I would like to have a macro that performs this sort. Problem is, the number of rows vary daily from from a few dozen to a few hundred. How can i accomplish this sort on data that changes daily? The header info is always in row 1, and the data starts in row 2. Please note, the data imported is not appended to existing data, each day is a new worksheet called DataImp. So the data imported will always start at row 2.

Thanks,

Tonso

Claus Busch

Sort on 3 columns when number of rows vary daily
 
Hi Tonso,

Am Mon, 14 Jan 2013 05:17:51 -0800 (PST) schrieb Tonso:

I daily download data to an XL2007 workbook. The data has 30 columns. It needs to be sorted, and I use Data, Sort to sort by 1. Date, Values, A to Z, 2. Then by Type, Values, Z to A, and 3. Then by Area, Values, Smallest to Largest. This works fine. I would like to have a macro that performs this sort. Problem is, the number of rows vary daily from from a few dozen to a few hundred. How can i accomplish this sort on data that changes daily? The header info is always in row 1, and the data starts in row 2. Please note, the data imported is not appended to existing data, each day is a new worksheet called DataImp. So the data imported will always start at row 2.


calculate your last cell and use it with sort:

Dim LRow As Long

LRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1:AD" & LRow).Sort.............


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2


All times are GMT +1. The time now is 12:32 AM.

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