From: Anita on
Hi - I am using v2007 and want to know code for selecting from row 2 to the
end of populated data in a spreadsheet. The length of the data will vary
everytime. Any help gratefully nreceived. Thanks. Anita
From: Rick Rothstein on
Assuming you mean you want to select entire rows, give this a try...

Dim LastRow As Long
LastRow = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
If LastRow > 1 Then Range("2:" & LastRow).Select

--
Rick (MVP - Excel)



"Anita" <Anita(a)discussions.microsoft.com> wrote in message
news:06E7F1F1-BB74-4992-A444-4208C569E002(a)microsoft.com...
> Hi - I am using v2007 and want to know code for selecting from row 2 to
> the
> end of populated data in a spreadsheet. The length of the data will vary
> everytime. Any help gratefully nreceived. Thanks. Anita

From: Gary''s Student on
Sub anita()
Dim r As Range, nLastRow As Long
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
Rows("2:" & nLastRow).Select
End Sub
--
Gary''s Student - gsnu201001


"Anita" wrote:

> Hi - I am using v2007 and want to know code for selecting from row 2 to the
> end of populated data in a spreadsheet. The length of the data will vary
> everytime. Any help gratefully nreceived. Thanks. Anita
From: Mike H on
Hi,

Try this

Rows("2:" & Cells.SpecialCells(xlLastCell).Row).Select
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Anita" wrote:

> Hi - I am using v2007 and want to know code for selecting from row 2 to the
> end of populated data in a spreadsheet. The length of the data will vary
> everytime. Any help gratefully nreceived. Thanks. Anita
From: Rick Rothstein on
That may not work correctly. Try this experiment. Go back to the worksheet
with your sample data and type something into any cell on a row, say, ten
rows down from the current end of your data. Now delete that entry by
selecting the cell and hitting the Delete key on your keyboard. Now run your
code and the selection should go down to the row you entered and then erased
the entry on (which is, if you used my suggestion, ten rows below the shown
end of data).

--
Rick (MVP - Excel)


"Mike H" <MikeH(a)discussions.microsoft.com> wrote in message
news:30223B62-C15E-4F61-B82F-7D0C9C6F09AF(a)microsoft.com...
> Hi,
>
> Try this
>
> Rows("2:" & Cells.SpecialCells(xlLastCell).Row).Select
> --
> Mike
>
> When competing hypotheses are otherwise equal, adopt the hypothesis that
> introduces the fewest assumptions while still sufficiently answering the
> question.
>
>
> "Anita" wrote:
>
>> Hi - I am using v2007 and want to know code for selecting from row 2 to
>> the
>> end of populated data in a spreadsheet. The length of the data will vary
>> everytime. Any help gratefully nreceived. Thanks. Anita