View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default How to Select Last Row of Sheet

i've used this befo

Sub test()
Dim ws As Worksheet
Dim lastcol As Long
Dim lastrow As Long
Dim arr As Variant
Dim i As Long

Set ws = Worksheets("Sheet1")
lastcol =12

ReDim arr(1 To lastcol)
For i = 1 To lastcol
arr(i) = ws.Cells(Rows.Count, i).End(xlUp).Row
Next
lastrow = Application.Max(arr)
End Sub


--


Gary

"Stephan Leduc" wrote in message
...
Thanks Andy.

Do you have something to select the Last Row for the Range A To L columns
?

Thanks

Stephan

"AndyM" wrote:

Cells(65536, 1).End(xlUp).Select

This will select the last row of data in column 1. This is the same as
clicking on cell A65536 and pressing Ctrl+Up.

"Stephan Leduc" wrote:

Hello,

I have a sub & function where I email the First (column headers) and
Last
Row of the Sheet. (Sheetname=VoiceMailData)

The email is working, and copying the data works fine. I just can't
select
the First and Last Row.

I have 12 columns. Here is my code:

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng = Cells(Rows.Count, "A").End(xlUp).Row
'You can also use a range if you want
'Set rng =
Sheets("YourSheet").Range("D4:D12").SpecialCells(x lCellTypeVisible)
On Error GoTo 0


Thanks

Stephan