ExcelBanter

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

mhayli

Selecting last row
 
I would like to write a macro in which a worksheet is firstly unprotected,
then the last row in the data entry field is copied then the row is "insert
copied row". The last data row may or may not have data in it and the row
number is variable. However, the last row into which data is entered is
always above a row that has "average" in the first column of that row.

Can tell me how I would write code to select the row above the "average" row??

Thanks.

[email protected]

Selecting last row
 
Hi mhayli,

Try this :
Sub TEST()
Dim ENDs As Object, ARow as Integer
Set ENDs = Range("A65536").End(xlUp) 'from the bottom chage
"A65536" to _ range you want to.
ARow = ENDs.Row
msgbox ARow ' here is the row
End Sub


mhayli menuliskan:
I would like to write a macro in which a worksheet is firstly unprotected,
then the last row in the data entry field is copied then the row is "insert
copied row". The last data row may or may not have data in it and the row
number is variable. However, the last row into which data is entered is
always above a row that has "average" in the first column of that row.

Can tell me how I would write code to select the row above the "average" row??

Thanks.



Kevin McCartney

Selecting last row
 

Dim rge as Range

set rge = activesheet.cells.SpecialCells(xlCellTypeLastCell)

HTH
KM

"mhayli" wrote:

I would like to write a macro in which a worksheet is firstly unprotected,
then the last row in the data entry field is copied then the row is "insert
copied row". The last data row may or may not have data in it and the row
number is variable. However, the last row into which data is entered is
always above a row that has "average" in the first column of that row.

Can tell me how I would write code to select the row above the "average" row??

Thanks.



All times are GMT +1. The time now is 08:34 AM.

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