ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find the last row number (https://www.excelbanter.com/excel-programming/295057-find-last-row-number.html)

Newbie

find the last row number
 
Hi,

I have some code that imports a text file into a template. In colums F-I
there are some formulaes that I need to copy down to the last row of the
imported text file. The last row can change everytime the file is imported.

How can I find which row is the last row and then copy the formulaes down?



Frank Kabel

find the last row number
 
Hi
try something like
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).row

--
Regards
Frank Kabel
Frankfurt, Germany


Newbie wrote:
Hi,

I have some code that imports a text file into a template. In colums
F-I there are some formulaes that I need to copy down to the last row
of the imported text file. The last row can change everytime the
file is imported.

How can I find which row is the last row and then copy the formulaes
down?



pikus

find the last row number
 
To find the last USED row use this:

lastUsedRow = Worksheets("Sheet1").UsedRange.Row
Worksheets("Sheet1").UsedRange.Rows.Count - 1

To find the first EMPTY row after the last used row omit the "- 1" lik
so:

firstEmptyRow = Worksheets("Sheet1").UsedRange.Row
Worksheets("Sheet1").UsedRange.Rows.Count

The same works with Columns:

lastUsedCol = Worksheets("Sheet1").UsedRange.Column
Worksheets("Sheet1").UsedRange.Columns.Count - 1

- Piku

--
Message posted from http://www.ExcelForum.com


Newbie

find the last row number
 
Thanks works a treat ! :-)
"pikus " wrote in message
...
To find the last USED row use this:

lastUsedRow = Worksheets("Sheet1").UsedRange.Row +
Worksheets("Sheet1").UsedRange.Rows.Count - 1

To find the first EMPTY row after the last used row omit the "- 1" like
so:

firstEmptyRow = Worksheets("Sheet1").UsedRange.Row +
Worksheets("Sheet1").UsedRange.Rows.Count

The same works with Columns:

lastUsedCol = Worksheets("Sheet1").UsedRange.Column +
Worksheets("Sheet1").UsedRange.Columns.Count - 1

- Pikus


---
Message posted from http://www.ExcelForum.com/




No Name

find the last row number
 

activesheet.cells(rows.count,1).end(xlUp).offset
(1,0).select


this will select the last cell in column A. if you want it
in a different column change 1 in cells(rows.coun,"col.
no").

you can get address of the cell by replacing ".select"
to ".address" and giving the whole statement a variable.

sorry i m not sure how you want to use it so maybe you
will find this too general.

-----Original Message-----
Hi,

I have some code that imports a text file into a

template. In colums F-I
there are some formulaes that I need to copy down to the

last row of the
imported text file. The last row can change everytime

the file is imported.

How can I find which row is the last row and then copy

the formulaes down?


.



All times are GMT +1. The time now is 10:37 AM.

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