Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting last row?


I want to have a macro that will select the cell in the last row in
column A. How do I do that?


--
edward0380
------------------------------------------------------------------------
edward0380's Profile: http://www.excelforum.com/member.php...o&userid=29396
View this thread: http://www.excelforum.com/showthread...hreadid=511077

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Selecting last row?

an example:

dim lastrow as long
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row

range("A" & lastrow).value = 1
--


Gary


"edward0380" wrote in
message ...

I want to have a macro that will select the cell in the last row in
column A. How do I do that?


--
edward0380
------------------------------------------------------------------------
edward0380's Profile:
http://www.excelforum.com/member.php...o&userid=29396
View this thread: http://www.excelforum.com/showthread...hreadid=511077



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Selecting last row?

this will do but why do you want to select. Try to write code that does not
require any selections.

lastrow=cells(rows.count,"a").end(xlup).row
cells(lastrow,"a").select

or
cells(lastrow,"a")=cells(44,4).value

--
Don Guillett
SalesAid Software

"edward0380" wrote
in message ...

I want to have a macro that will select the cell in the last row in
column A. How do I do that?


--
edward0380
------------------------------------------------------------------------
edward0380's Profile:
http://www.excelforum.com/member.php...o&userid=29396
View this thread: http://www.excelforum.com/showthread...hreadid=511077



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 210
Default Selecting last row?

range("a1").Offset(sheet1.UsedRange.Row-1).Select

Replace sheet1 with the sheet object name.
--
http://HelpExcel.com
1-888-INGENIO
1-888-464-3646
x0197758


"edward0380" wrote:


I want to have a macro that will select the cell in the last row in
column A. How do I do that?


--
edward0380
------------------------------------------------------------------------
edward0380's Profile: http://www.excelforum.com/member.php...o&userid=29396
View this thread: http://www.excelforum.com/showthread...hreadid=511077


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Selecting last row?

Hi,

UsedRange can be unreliable for finding the last known row/column.

Also, Rows.Count/End(xlUp) will not look at formulas which return a null
value.

--
Regards,
Zack Barresse, aka firefytr, (GT = TFS FF Zack)
To email, remove the NO SPAM. Please keep correspondence to the board, as
to benefit others.


"galimi" wrote in message
...
range("a1").Offset(sheet1.UsedRange.Row-1).Select

Replace sheet1 with the sheet object name.
--
http://HelpExcel.com
1-888-INGENIO
1-888-464-3646
x0197758


"edward0380" wrote:


I want to have a macro that will select the cell in the last row in
column A. How do I do that?


--
edward0380
------------------------------------------------------------------------
edward0380's Profile:
http://www.excelforum.com/member.php...o&userid=29396
View this thread:
http://www.excelforum.com/showthread...hreadid=511077






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Selecting last row?

The previous replies are all ok, but they might not be exact.

I have used the following function for years now, and it ALWAYS give steh
correct result.

I got it from Rob Bovey and then added a few lines

Function Goto_Last(strRange, int_col, int_row)
On Error Resume Next
Application.ScreenUpdating = False
Cells(Cells.Find("*", Range("A1"), , , xlByRows, xlPrevious).Row, _
Cells.Find("*", Range("A1"), , , xlByColumns, xlPrevious).column).Select
If Err.Number < 0 Then MsgBox "No data in sheet"
Application.ScreenUpdating = True
strRange = ActiveCell.AddressLocal
int_col = ActiveCell.column
int_row = ActiveCell.Row
End Function

You just add a line to your macro to call the function, and then use the
data it returns.

--
Alan Hutchins


"edward0380" wrote:


I want to have a macro that will select the cell in the last row in
column A. How do I do that?


--
edward0380
------------------------------------------------------------------------
edward0380's Profile: http://www.excelforum.com/member.php...o&userid=29396
View this thread: http://www.excelforum.com/showthread...hreadid=511077


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
row selecting climate Excel Worksheet Functions 3 October 12th 08 05:57 AM
Selecting the Same Steve COR Excel Discussion (Misc queries) 0 January 2nd 08 04:13 PM
Selecting Hutchy Excel Discussion (Misc queries) 3 October 12th 07 11:43 AM
VBA - Selecting a Row Elise148 Excel Discussion (Misc queries) 5 June 12th 07 04:29 PM
Selecting The Last Row Minitman[_4_] Excel Programming 15 July 25th 05 03:11 AM


All times are GMT +1. The time now is 05:35 AM.

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

About Us

"It's about Microsoft Excel"