Sort on 3 columns when number of rows vary daily

T

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.

Thanks,

Tonso
 
C

Claus Busch

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top