Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50049

Sorting - how to select part of worksheer

$
0
0
I am trying to create a VBA Macro that sorts the data on a worksheet.

I have 10 rows of header junk that I want left as is, then 300 to 500 rows of
data I want sorted - on data of a particular column.

Right now its 340 ... and this works (sorting on col M)


Code:

Worksheets("Out").Range("A11:M999").Sort _
        Key1:=Worksheets("Out").Range("M11"), _
      order1:=xlAscending

What if I go past 1000 rows ? So, I wanted a way to make it work for any number of
rows. I tried this,



Code:

Worksheets("Out").Range("A11").End(xlDown).Sort _
        Key1:=Worksheets("Out").Range("M11"), _
        order1:=xlAscending

but my header data in row 10 ended up getting pushed to the very last row. It apparently
was included in the sort.

How can I get this done correctly ?

Viewing all articles
Browse latest Browse all 50049

Trending Articles