I want to have a macro that will select the cell in the last row in column A. How do I do that?
I want to have a macro that will select the cell in the last row in column A. How do I do that?
an example:
dim lastrow as long
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
range("A" & lastrow).value = 1
--
Gary
"edward0380" <edward0380.230skm_1139586002.1003@excelforum-nospam.com> wrote in
message news:edward0380.230skm_1139586002.1003@excelforum-nospam.com...
>
> 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
>
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
dguillett1@austin.rr.com
"edward0380" <edward0380.230skm_1139586002.1003@excelforum-nospam.com> wrote
in message news:edward0380.230skm_1139586002.1003@excelforum-nospam.com...
>
> 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
>
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
>
>
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" <ed@HelpExcel.com> wrote in message
news:CDA74E02-35FF-4860-AC0A-C6742CA42C74@microsoft.com...
> 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
>>
>>
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
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks