Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to Select Last Row of Sheet

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default How to Select Last Row of Sheet

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to Select Last Row of Sheet

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How to Select Last Row of Sheet

hi
select first and last row.
select first row......entire row

Range("A1").EntireRow.Select

select cells in first row with data in cells(assumes a solid row of data).

Range(Range("A1"), Range("A1").End(xlToRight)).Select

select last row - entire row

lr = Cells(Rows.Count, "A").End(xlUp).Row
Rows(lr).EntireRow.Select

select cells in last row with data in cells(assumes a solid row of data).

lr = Cells(Rows.Count, "A").End(xlUp).Row
Range(Range("A" & lr), Range("A" & lr).End(xlToRight)).Select

Regards
FSt1

"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

  #5   Report Post  
Posted to microsoft.public.excel.programming
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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How to Select Last Row of Sheet

hi
supplimental
select cells in first row with data in cells(data not in all cells).

lc = Cells(1, Columns.Count).End(xlToLeft).Column
Range(Cells(1, 1), Cells(1, lc)).Select"

select cells in last row with data in cells(data not in all cells).

lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, "A").End(xlUp).Row
Range(Cells(lr, 1), Cells(lr, lc)).Select

lot of ways to do this.
regards
FSt1

FSt1" wrote:

hi
select first and last row.
select first row......entire row

Range("A1").EntireRow.Select

select cells in first row with data in cells(assumes a solid row of data).

Range(Range("A1"), Range("A1").End(xlToRight)).Select

select last row - entire row

lr = Cells(Rows.Count, "A").End(xlUp).Row
Rows(lr).EntireRow.Select

select cells in last row with data in cells(assumes a solid row of data).

lr = Cells(Rows.Count, "A").End(xlUp).Row
Range(Range("A" & lr), Range("A" & lr).End(xlToRight)).Select

Regards
FSt1

"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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternate Row Select in Sheet 1 then Paste to Sheet 2 Steevo Excel Worksheet Functions 4 December 5th 08 06:45 PM
Select sheet, Pause till Enter pressed, return to previous sheet Russ3Z Excel Programming 1 June 12th 07 11:06 PM
How do I select price from sheet.b where sheet.a part no = sheet.b Sonny Excel Worksheet Functions 4 April 4th 06 05:08 PM
Use of Sheet CodeNames to Select Sheet in Different Workbook Randy[_10_] Excel Programming 10 June 14th 05 04:55 AM
Select Sheet then Select Range Gee[_2_] Excel Programming 3 May 27th 04 10:10 PM


All times are GMT +1. The time now is 12:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"