LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Solution: Actual Row Count

I wrote a brief function for returning the actual last row in a
worksheet regardless of empty, formerly used rows. Neither
"ActiveSheet.UsedRange.Rows.Count" nor "Cells(Rows.Count,
1).End(xlUp).Row" work consistently enough to be 100% reliable.
Here's the function I came up with that seems to work pretty well. I
know it takes a little more processing than the other two methods, but
if you're more concerned about accuracy then this should work for you:

Public Function GetRowCount() As Double
'gets a count of the used rows in a worksheet
'This is a literal count and DOES NOT take
'empty rows into consideration

Dim dX As Double, dY As Double, dZ As Double
Dim dTemp As Double, dResults As Double

dX = ActiveSheet.UsedRange.Rows.Count
dY = ActiveSheet.UsedRange.Columns.Count

For dZ = 1 To dY
dTemp = Cells(Rows.Count, dZ).End(xlUp).Row
If dTemp dResults Then dResults = dTemp
Next
GetRowCount = dResults
End Function

Of course I'm open to better, more efficient ways of doing this :-)

Thanks!

Cory

 
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
actual/360 and 30/360 amortization? Terry Excel Worksheet Functions 4 April 3rd 23 02:42 PM
Why is the actual calculation different from actual sample Joe Excel Discussion (Misc queries) 4 May 1st 10 11:46 PM
actual row number climate Excel Worksheet Functions 3 March 17th 10 07:59 AM
How to programmatically determine actual page count in Excel 2003? GopherDude Excel Programming 0 September 4th 07 08:46 PM
xnpv with actual/360 Anand Excel Worksheet Functions 1 January 19th 06 04:18 AM


All times are GMT +1. The time now is 01:20 AM.

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"