Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Fad
 
Posts: n/a
Default Get the number of last row entry

I have a common macro that will run on different files. Since these files
are of different sizes, is there a function that will return the number of
rows in the file instead of going each time and change the number.

Thank you
  #2   Report Post  
papou
 
Posts: n/a
Default

Hello Fad
Range("A65536").End(xlUp).Row
Which will give the last non empty row in column A.

HTH
Cordially
Pascal


"Fad" a écrit dans le message de news:
...
I have a common macro that will run on different files. Since these files
are of different sizes, is there a function that will return the number of
rows in the file instead of going each time and change the number.

Thank you



  #3   Report Post  
David McRitchie
 
Posts: n/a
Default

Hi Fad,
Pascal's code correctly provides for skipping over empty cells, but the
65536 would be best not used, in case Excel gets more rows,
it has happened. The number of columns hasn't changed since
Excel first started and is LONG overdue, and if it does get changed
you will have a mixture of people having one or the other for several
years.

The following would be equivalent and would continue to work in future,
and is based on Column A as Pascal's code, not on the lastcell as
maintained (or not) by Excel:

Dim rw as long '-- integer only goes to 32768
rw = Cells(Rows.Count, 1).End(xlUp).Row

Some useful macros that I have on my toolbar making use of this can be found at
http://www.mvps.org/dmcritchie/excel/tools.htm#macros
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"papou" wrote in message ...
Hello Fad
Range("A65536").End(xlUp).Row
Which will give the last non empty row in column A.

HTH
Cordially
Pascal


"Fad" a écrit dans le message de news:
...
I have a common macro that will run on different files. Since these files
are of different sizes, is there a function that will return the number of
rows in the file instead of going each time and change the number.

Thank you





  #4   Report Post  
papou
 
Posts: n/a
Default

Hello David
Yes good thing!
I will try and keep it in mind ;-)

Cordially
Pascal

"David McRitchie" a écrit dans le message de news:
...
Hi Fad,
Pascal's code correctly provides for skipping over empty cells, but the
65536 would be best not used, in case Excel gets more rows,
it has happened. The number of columns hasn't changed since
Excel first started and is LONG overdue, and if it does get changed
you will have a mixture of people having one or the other for several
years.

The following would be equivalent and would continue to work in future,
and is based on Column A as Pascal's code, not on the lastcell as
maintained (or not) by Excel:

Dim rw as long '-- integer only goes to 32768
rw = Cells(Rows.Count, 1).End(xlUp).Row

Some useful macros that I have on my toolbar making use of this can be
found at
http://www.mvps.org/dmcritchie/excel/tools.htm#macros
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"papou" wrote in message
...
Hello Fad
Range("A65536").End(xlUp).Row
Which will give the last non empty row in column A.

HTH
Cordially
Pascal


"Fad" a écrit dans le message de news:
...
I have a common macro that will run on different files. Since these
files
are of different sizes, is there a function that will return the number
of
rows in the file instead of going each time and change the number.

Thank you







  #5   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Hi Fad

You can use the function on this page
http://www.rondebruin.nl/copy1.htm

Function LastRow(sh As Worksheet)
On Error Resume Next
LastRow = sh.Cells.Find(What:="*", _
After:=sh.Range("A1"), _
Lookat:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row
On Error GoTo 0
End Function


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Fad" wrote in message ...
I have a common macro that will run on different files. Since these files
are of different sizes, is there a function that will return the number of
rows in the file instead of going each time and change the number.

Thank you





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
Seed numbers for random number generation, uniform distribution darebo Excel Discussion (Misc queries) 3 April 21st 23 09:02 PM
How do I start an Excel entry with then number 0? cajundoc Excel Discussion (Misc queries) 2 April 20th 05 08:23 PM
Want a number of cells to be auto completed based on entry in one. matt ashley Excel Worksheet Functions 1 April 14th 05 10:07 PM
number entry tom donino Excel Worksheet Functions 1 December 24th 04 09:03 AM
GET.CELL Biff Excel Worksheet Functions 2 November 24th 04 07:16 PM


All times are GMT +1. The time now is 04:42 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"