Sort a Dynamic Range

J

John

Is it possible to sort a range that is continually added to via VB?

I know the columns and start row that I wish to sort but don't know the
'ending' row as I will have another piece of code that will paste in my
values to a worksheet. Every time I export in to this worksheet the 'ending'
row will possibly change.

Thanks
 
B

Bob Phillips

John,

Set rng = Range("A1:G1").Resize(Cells(Rows.Count,"A").End(xlUp).Row,7)

will identify your dynamic range, and just sort rng as normal.

You will need to tailor A1:G1, and the ,7 to suit your columns.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
J

John

Thanks Bob, very handy


Bob Phillips said:
John,

Set rng = Range("A1:G1").Resize(Cells(Rows.Count,"A").End(xlUp).Row,7)

will identify your dynamic range, and just sort rng as normal.

You will need to tailor A1:G1, and the ,7 to suit your columns.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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