View Single Post
  #18   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Determining the row limit in a macro

Still a typo, which I think can be fairly blamed on trying to correct Jeff's
<g

change
Case Is 10
to
Case Is 11 ' later than xl2003
or
Case Is = 12

Peter T


"Rick Rothstein" wrote in message
...
As Peter pointed out, I have the number of rows reversed...

Function MaxRow(ByVal Version As Double) As Long
Select Case Application.Version
Case Is 10
MaxRow = 2 ^ 20 ' This equals 1048576
Case Else
MaxRow = 2 ^ 16 ' This equals 65536
End Select
End Function

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Still some problems with your code. First off, you need to specify
Application.Version and not just Version by itself for the object of the
Select Case statement. Second, any version greater than 9 (that is, 10,
11, 12, etc.) will be trapped by your first Case statement... you have to
test the higher numbered versions first. Also, did you separate Versions
9 and 10 instead of combining them a single Case statement (which, by the
way, won't be necessary once you reverse the order of the tests)? Also,
so you don't have to remember those large numbers, you can use powers of
2 instead...

Function MaxRow(ByVal Version As Double) As Long
Select Case Application.Version
Case Is 10
MaxRow = 2 ^ 16 ' This equals 65536
Case Else
MaxRow = 2 ^ 20 ' This equals 1048576
End Select
End Function

--
Rick (MVP - Excel)


"Jeff" wrote in message
...
thanks Tom

Function MaxRow(ByVal Version As Double) As Long
Select Case Version
Case Is 9
MaxRow = 65536
Case 10#
MaxRow = 65536
Case Is 10
MaxRow = 1048576
End Select
End Function

"Tom Ogilvy" wrote:

Jeff,

I printed out the results for versions 1 to 12.

1 1048576
2 1048576
3 1048576
4 1048576
5 1048576
6 1048576
7 1048576
8 1048576
9 1048576
10 65536
11 65536
12 65536

that doesn't seem correct to me. You must have something mixed up in
your
UDF.

Just a heads up.

--
Regards,
Tom Ogilvy


"Jeff" wrote:

reurn max number of rows by version

Function MaxRow(ByVal Version As Double) As Long
Select Case Version
Case Is 9
MaxRow = 65536
Case 10#
MaxRow = 65536
Case Is < 10
MaxRow = 1048576
End Select
End Function

"Ryan H" wrote:

This will count the number of rows available in whichever Excel
version you
use. Hope this helps! If so, let me know, click "YES" below.

Sub CountRows()

Dim NumberOfRows As Long

NumberOfRows = Rows.Count
MsgBox NumberOfRows

End Sub
--
Cheers,
Ryan


"Phil Hibbs" wrote:

How can a macro determine what the maximum number of rows is in
the
version of Excel that is running? I don't want to just hard-code
version numbers, and I don't want to use .end(xldown) either.

Phil Hibbs.
.