ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting last row? (https://www.excelbanter.com/excel-programming/353001-selecting-last-row.html)

edward0380[_3_]

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


Gary Keramidas

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




Don Guillett

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




galimi

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



Zack Barresse[_3_]

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





Alan Hutchins[_2_]

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




All times are GMT +1. The time now is 10:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com