View Single Post
  #14   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

I think we can ignore versions prior to 97 with only 16k rows, so we are
only need to test if Excel is version 12 (2007) or newer to know if it is
capable of handling 1048576 rows, if not the maximum is 65336. See the
simple example I posted in my previous reply to you.

I appreciate the OP asked about maximum rows by version, even so I thought
worthwhile to mention it is normally the workbook in question that needs to
be considered, rather than the Excel version.

Regards,
Peter T


"Jeff" wrote in message
...
Tom pointed out the typo in the UDF, The original post asked for the
maximum
number of row by version.

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.


"Peter T" wrote:

That function will return 65536 rows for all versions from Excel 2000,
there
are several things wrong with it. You could perhaps do something like
this -

If val(application.version) =12 then
maxrows = 1048576
else
maxrows = 65536
end if.

However normally the programmer will want to know the number of rows in
the
worksheet, which depending on the fileformat is not necessarily the same
as
the maximum number of rows the version can handle.

Regards,
Peter T

"Jeff" wrote in message
...
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.
.



.