Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default How to find maximum non-blank row number without brute force method?

Anyone know how to get the maximum non-blank row number in a range of
columns? I am looking for an answer in a couple lines because i can
probably just do it by brute force using code like ,

for colx =1 to 5
maxrow=cells(65535,colx).end(xlendup)
if maxrow newmax then newmax=maxrow
next colx
newmax would of course be the maximum row number in the range of
columns 1-5.

But i was looking for something maybe in an array format formula? with
one line of code.(doesn't have to be an array though)
Thanks,
Chet


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default How to find maximum non-blank row number without brute force method?

Hi Chet

I think that I would use same approch as you, with a little modification.

Dim MaxRow As Integer
For ColX = 1 To 5
If Range(Cells(65535, ColX)).End(xlUp).Row MaxRow Then _
MaxRow = Range(Cells(65535, ColX)).End(xlUp).Row
Next ColX

Regards,
Per

"Chet" skrev i meddelelsen
...
Anyone know how to get the maximum non-blank row number in a range of
columns? I am looking for an answer in a couple lines because i can
probably just do it by brute force using code like ,

for colx =1 to 5
maxrow=cells(65535,colx).end(xlendup)
if maxrow newmax then newmax=maxrow
next colx
newmax would of course be the maximum row number in the range of
columns 1-5.

But i was looking for something maybe in an array format formula? with
one line of code.(doesn't have to be an array though)
Thanks,
Chet



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to find maximum non-blank row number without brute force metho

Hi,

Try this

Sub stantial()
Set myrange = Range("A:E")
mymax = WorksheetFunction.Max(myrange)
End Sub

If you need to you can trap for zero with an IF statement
If mymax=0 then

Mike

"Chet" wrote:

Anyone know how to get the maximum non-blank row number in a range of
columns? I am looking for an answer in a couple lines because i can
probably just do it by brute force using code like ,

for colx =1 to 5
maxrow=cells(65535,colx).end(xlendup)
if maxrow newmax then newmax=maxrow
next colx
newmax would of course be the maximum row number in the range of
columns 1-5.

But i was looking for something maybe in an array format formula? with
one line of code.(doesn't have to be an array though)
Thanks,
Chet



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
Maximum Number of Blank Cells between Non Blank Cells in a Range Mal Excel Worksheet Functions 5 November 3rd 07 08:21 AM
SaveAs Method adding a large number of comma-delimited blank lines [email protected] Excel Programming 2 October 19th 07 08:58 PM
function to find the row number of the maximum value in a coll josht Excel Worksheet Functions 0 January 23rd 07 06:25 PM
another lookup brute force question been drilbled to 2007 Excel Discussion (Misc queries) 8 January 4th 07 04:38 PM
Find row number of maximum value CGeorges Excel Programming 2 February 2nd 04 08:51 PM


All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"