Help with formula - variant of last row problem/s

henryg

Board Regular
Joined
Oct 23, 2008
Messages
152
Office Version
  1. 365
Platform
  1. Windows
I have a lookup list (but not a table!) with names vertically, and a data table with names (that should be?) in the lookup list horizontally, eg

Lookup List
V
W
X
Y
Z

Table columns (MnthData)
A, V, W, X, Y, Z, where A contains dates in ascending order. The column order may not be the same as the list.

I want to lookup a name in the lookup list eg Z and return the latest value from (last row of) the data table where the header is "Z".

Bearing in mind I have attempted to simplify the example and my formula below, not a bad thing, I end up with

=XLOOKUP($V$9:$V$13,MnthData[[#Headers],{B]:[F]],INDIRECT("B"&COUNT(MnthData[Date])+8):INDIRECT("F"&COUNT(MnthData[Date])+8),"")

+8 because that's where the data in the MnthData data table starts.

This works (at least in my full version of the formula), but I really dislike using INDIRECT(). So I'm looking for a better way of doing it.

I may have messed up simplifying the formula but hope you get the idea.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi, not if I've understood correctly, but maybe something like this:

Book3
ABCDEFGHI
1
2
3
4
5
6
7AXVYZWLookup ListLast Value
801-Jan2375778717341V7
902-Jan1684599212215W766
1003-Jan7426329367732X280
1104-Jan7517258671896Z143
1205-Jan3988821413610
1306-Jan438984441847
1407-Jan2807585143766
Sheet1
Cell Formulas
RangeFormula
I8:I11I8=TAKE(INDEX(MnthData,0,MATCH(H8,MnthData[#Headers],0)),-1)
 
Upvote 0
I've always had problems using index/match, so jump to XLOOKUP(). I did have an index/match version but it could not cope when the table headers order was not the same as the lookup list. I'll give this a try.

And you've used TAKE() which I've really wanted to use (y)

Thank you.
 
Upvote 0
You could also use:

=XLOOKUP($V$9:$V$13,MnthData[#Headers],INDEX(MnthData,COUNT(MnthData[Date]),0))

if you didn't have TAKE available yet.
 
Upvote 0
After trying both of the above solutions, and breaking down each component into separate cells, I ended up with

=XLOOKUP(V9:V21,MnthData[#Headers],TAKE(MnthData,-1))

which gives what I wanted without INDIRECT; and is much clearer than my (full) original formula.

Thank you both for the help. Much better than ChatGPT ;)
 
Upvote 0

Forum statistics

Threads
1,224,524
Messages
6,179,304
Members
452,904
Latest member
CodeMasterX

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