Sorting rows with macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro which imports a .htm file from another application then sorts the rows,

The problem is that the number of rows in the import file varies. In writing the macro I use ctrl downarrow to select the last cell in the column, select that cell - scroll to the top select the range. Even though I used ctrl keys to select the range Excel takes the values as absolute

How can I make the Range selection relative. First cell to last cell regardless of the length of the file
 
Raymond,

You can calculate the number of rows as follows

Cells(Rows.Count,"A").End(xlUp).Row

which checks down column. The range can be calculated as

rng = Range("A1", "H" & Cells(Rows.Count,"A").End(xlUp).Row)

obviously change the columns to suit

--

HTH

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

Raymond said:
I have a macro which imports a .htm file from another application then sorts the rows,.

The problem is that the number of rows in the import file varies. In
writing the macro I use ctrl downarrow to select the last cell in the
column, select that cell - scroll to the top select the range. Even though I
used ctrl keys to select the range Excel takes the values as absolute.
How can I make the Range selection relative. First cell to last cell
regardless of the length of the file.
 

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

Back
Top