Find last row with a numeric value in a range

JCK101

New Member
Joined
Feb 1, 2012
Messages
32
Office Version
  1. 2019
Platform
  1. Windows
I'm trying to find the last row with a numeric value in a range (R8:X57).

I tried this: =MIN(ROW(R8:X57))+ROWS(R8:X57)-1

The result was 57 instead of 11 since the rows 12 to 57 have no values, but do have formulas.

I tried =LOOKUP(2,1/(LEN(R:X)>0),ROW(INDIRECT("1:65536"))) the result is 7 instead of 11, 7 is the heading row.

I tried this next one, it works, but it is too UGLY: =MAX(LOOKUP(2,1/(LEN(R:R)>0),ROW(INDIRECT("1:65536"))),LOOKUP(2,1/(LEN(S:S)>0),ROW(INDIRECT("1:65536"))), LOOKUP(2,1/(LEN(T:T)>0),ROW(INDIRECT("1:65536"))),LOOKUP(2,1/(LEN(U:U)>0),ROW(INDIRECT("1:65536"))),LOOKUP(2,1/(LEN(V:V)>0),ROW(INDIRECT("1:65536"))),LOOKUP(2,1/(LEN(W:W)>0),ROW(INDIRECT("1:65536"))),LOOKUP(2,1/(LEN(X:X)>0),ROW(INDIRECT("1:65536"))))

Any help will be appreciated.

Regards,
JC
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Here is one way to do it. This is an array-entered** formula...

=MAX(ISNUMBER(R8:X57)*ROW(R8:X57))

**Commit this formula using CTRL+SHIFT+ENTER and not just Enter by itself.
 
Upvote 0
.. and if you were looking for a non array-entered formula, you could try

=AGGREGATE(14,6,ROW(R8:R57)/ISNUMBER(R8:X57),1)
 
Upvote 0
Thank you Rick, yours works too, but I prefer the non-Array.
 
Last edited:
Upvote 0
Would this formula work if I moved the formula to another sheet? The data will stay in the original sheet.

If this is considered a new thread, I will start another one, just let me know.
 
Upvote 0
Would this formula work if I moved the formula to another sheet? The data will stay in the original sheet.
Sure. If the original sheet is called, say 'Current Data' then the formula on another sheet would be:

=AGGREGATE(14,6,ROW('Current Data'!R8:R57)/ISNUMBER('Current Data'!R8:X57),1)
 
Last edited:
Upvote 0


=AGGREGATE(14,6,ROW('Current Data'!R8:R57)/ISNUMBER('CurrentData'!R8:X57),1)


Thank you [bold]very much[/bold] Peter for introducing me to Jeanie HTML!

Above formula worked like a charm.

I looked up what the numbers 14 and 6 mean, andI can use them in the future. :)

Also, what if we want to use the INDIRECT formulafrom a "LookupSheet" to lookup the same value on multiple data sheets one at a time?

e.g. The original data is in"DataSheet1", on the "LookupSheet" in Cell A2 I entered"DataSheet1".

Like this: =AGGREGATE(14,6,ROW(INDIRECT(A2&"!"&R8:R57,FALSE))/ISNUMBER(INDIRECT(A2&"!"&R8:X57)),1)

This did not work.
<!--[if !supportLineBreakNewLine]-->
Again thank you for all your help and time for making our lives a lot less distressful.

RJ
Excel Workbook
AB
1Name of sheet to lookupMax Row # in DataSheet1 (Hard coded) columns R--X
2DataSheet15
3
4
5Indirect function (False) sheet named in cell A2 (i.e., DataSheet1) columns R--X
6#NUM!
7
8
9
10Indirect function (True) sheet named in cell A2 (i.e., DataSheet1) columns R--X
11#NUM!
12
LookupSheet
Excel Workbook
QRSTUVWXY
1ItemAItemBItemCItemDItemEItemFItemG
2105103101
3106104102
4107
5108
6
7
8
9
10
DataSheet1
Excel Workbook
QRSTUVWXY
1ItemAItemBItemCItemDItemEItemFItemG
2201203209211214
3202204210212215
4205213216
5206217
6207
7208
8
9
10
DataSheet2
 
Last edited:
Upvote 0
Also, what if we want to use the INDIRECT formulafrom a "LookupSheet" to lookup the same value on multiple data sheets one at a time?

e.g. The original data is in"DataSheet1", on the "LookupSheet" in Cell A2 I entered"DataSheet1".
You have the syntax slightly wrong and I would also include the ' around the sheet name just in case a sheet name ever includes any spaces.

=AGGREGATE(14,6,ROW(INDIRECT("'"&A2&"'!R2:R59"))/ISNUMBER(INDIRECT("'"&A2&"'!R2:X59")),1)


Thank you [bold]very much[/bold] Peter for introducing me to Jeanie HTML!
You are welcome.

BTW, the tags for bold should just contain B and /B not the whole word.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,600
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top