Dynamic lookup and return value of last non-blank cell in that column

Silverhorne

New Member
Joined
Feb 21, 2015
Messages
42
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Good morning,

I am working in Excel2019, I have been using index/match formulas to get most of what I need from my sheet but can't figure out how to get what I need with this one.
The below formula is incomplete but it shows the row I need from another tab:
=INDEX(Depth!$B$2:$ZZ$100,MATCH($C3,Depth!$B$2:$ZZ$2,0))
What I would like to do is find the last cell in this row that contains a value.
I am not sure if index/match will work for this, possibly some other lookup function that finds a dynamic value (in this case $C3) in a row (Depth!$B$2:$ZZ$2) on another tab and then displays the contents of the last populated cell in this column.

Any help is much appreciated!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Check if you need this

Book1
ABCDEFGHIJKLMNOP
1bcdefghijklmnop
2b2c2d2e2f2g2amori2j2k2l2amorn2o2p2
3amor
4m10
5
6
7
8
9
10b10c10d10e10f10g10h10i10j10k10l10m10n10o10p10
Sheet
Cell Formulas
RangeFormula
B4B4=LOOKUP(2,1/(B2:Z2=C3),B10:Z10)
 
Upvote 0
Thank you for the answer but not what I need. I need something that finds the last cell in a column but the column number is a dynamic value. Most of the formulas to find the last cell in a column with data require a specific column reference (A1:A100). Your method locks the results to row 10 when the results I need may be in row 7 in C, 4 in H, etc.

This formula gives the last cell in a column with data:
=LOOKUP(2,1/(A$6:A$8<>""),A$1:A$8)

This formula would be on another tab and reference a cell to match in the top row:
INDEX(Depth!$A$1:$I$8,MATCH($C3,Depth!$A$1:$I$1,0))

So if the reference cell had "P1-05" it would look for this in row A and return 5, if the reference cell was "P1-02" it would look for this in row A and return 4.
Depth:
P1-01P1-02P1-03P1-04P1-05P1-06P1-07P1-08P1-09
221232323
32445553
3344543
44545
44
55
5
 
Upvote 0
Assuming the reference cell is C3 on the formula sheet"

=LOOKUP(1E+307,INDEX(Depth!$A$1:$I$8,0,MATCH(C3,Depth!$A$1:$I$1,0)))
 
Upvote 0
Thank you so much JoeMo! I racked my brain for a good 5 hours trying to figure something out.
 
Upvote 0
You are welcome - thanks for the reply.
 
Upvote 0
From your sample data in post 3 it looks like this will indeed meet your needs, but just be aware that the formula will return the "last numeric value in the column", not necessarily the
"last non-blank cell in that column" as in your thread title or " the last cell ... that contains a value" as written in post 1.
 
Upvote 0
Sorry for the delay. Here is my answer, considering that the desired value may be a text or a number.

Book1
ABCDEFGHI
1P1-01P1-02P1-03P1-04P1-05P1-06P1-07P1-08P1-09
22211232323
3322445553
432344543
5244545
6the last value44
755
85
Depth

Array formulas:
Book1
ABCD
1
2
3P1-02P1-05
4the last value5
Sheet1
Cell Formulas
RangeFormula
C4:D4C4{=INDEX(Depth!$A$2:$I$8,MAX(IF(Depth!$A$1:$I$1=C3,IF(Depth!$A$2:$I$8<>"",ROW(Depth!$A$2:$I$8))))-1,MATCH(C3,Depth!$A$1:$I$1,0))}
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
Another option with a "regular" formula

Book1
ABCD
1
2
3P1-02P1-05
4the last value5
Sheet1
Cell Formulas
RangeFormula
C4:D4C4=INDEX(Depth!$A$1:$I$8,SUMPRODUCT(MAX((Depth!$A$1:$I$1=C3)*(Depth!$A$1:$I$8<>"")*(ROW(Depth!$A$1:$I$8)))),MATCH(C3,Depth!$A$1:$I$1))
 
Upvote 0
Thank you all so much!
The original solution worked but I ran into a situation where I needed the array formula due to a letter added to the last cell.
I got 2 birds with 1 stone!! That made my day!
 
Upvote 0

Forum statistics

Threads
1,215,419
Messages
6,124,798
Members
449,189
Latest member
kristinh

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