Sort a Dynamic Range

  • Thread starter Thread starter John
  • Start date Start date
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
 
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)
 
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)
 
Back
Top