Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default 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/



  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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?


.

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
Find number of weekdays and wekend days given a total number of da Juan Correa Excel Discussion (Misc queries) 7 February 19th 10 09:47 PM
Find previous number and find next number in column DoubleZ Excel Discussion (Misc queries) 4 March 4th 09 08:51 PM
Need Cells.find to find first number in a row which is 8000 Kasper Excel Discussion (Misc queries) 9 December 15th 08 02:10 PM
find the frequency a number appears with another number within a s greenmachine Excel Worksheet Functions 10 September 11th 07 03:19 AM
countif formula to find the occurances of a number that is greater than one number but less than another steveo Excel Discussion (Misc queries) 3 July 8th 06 02:04 AM


All times are GMT +1. The time now is 11:48 PM.

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"