How to lookup a value from several rows in a table using INDEX and MATCH

plan

New Member
Joined
May 7, 2021
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone,
First post, so be gentle! I have spent hours trying to work out a solution to this issue, and know someone here will know the answer.

We have data in a large table with a column for each month and then new rows for each year (see screenshot). I need to lookup the value corresponding to a future date. The obvious way to do this is with an Array Formula using Index and Match. I'm reluctant to use Helper Cells, as there are 650 rows in the table, so this will make the table very large and confusing (the screenshot is a small subset of the data). I'm also reluctant to move everything to one row for the same reason. We use Excel 2019 so we can't use a Dynamic Array. Please can someone point me in the right direction?

Jason
Excel spreadsheet.jpg
 

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.
Welcome to Mr. Excel...

If you would please use XL2BB to post your sample data, anyone trying to solve your problem won't have to recreate your data.

What is the answer you want where the #value! appears? Is it 107,452.64?
 
Upvote 0
How are there 600+ rows? Is there another block of 5 rows for Feb 2024 through Jan 2025, etc., etc.? Then, where is your search being placed in the data -- below 600+ rows?
 
Upvote 0
Hi Kweaver,
Thank you for your prompt response. Yes, I'm looking to return the value after charges for the date in question - £107,452.64 in this example.
The reason for 600+ rows is that we are calculating the charges up to 40 years into the future, and each year has a dozen different rows to show values before and after different fees.
I've pasted a subset of the data below. Thanks so much for your help!

Book1
ABCDEFGHIJKLM
1MonthFeb-21Mar-21Apr-21May-21Jun-21Jul-21Aug-21Sep-21Oct-21Nov-21Dec-21Jan-22
2Investment Charges£11.64£11.68£11.73£11.77£11.82£11.86£11.91£11.95£12.00£12.04£12.09£12.13
3Adviser Charges£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00
4Platform Service Fee£16.73£16.80£16.86£16.92£16.99£17.05£17.12£17.18£17.25£17.31£17.38£17.44
5Value After Charges£100,379.04£100,759.51£101,141.42£101,524.78£101,909.59£102,295.86£102,683.59£103,072.79£103,463.47£103,855.63£104,249.28£104,644.42
6MonthFeb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23
7Investment Charges£12.18£12.23£12.27£12.32£12.37£12.41£12.46£12.51£12.55£12.60£12.65£12.70
8Adviser Charges£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00
9Platform Service Fee£17.51£17.58£17.64£17.71£17.78£17.84£17.91£17.98£18.05£18.12£18.18£18.25
10Value After Charges£105,041.06£105,439.20£105,838.85£106,240.01£106,642.69£107,046.90£107,452.64£107,859.92£108,268.75£108,679.12£109,091.05£109,504.54
11
12Future value date:31/08/22
13Value after charges on that date:
Sheet1
 
Upvote 0
I tried a macro with dates messed with because I have a US date on my system. And, I moved the search info away from the potential 600+ lines.
See what you think:

Book3
ABCDEFGHIJKLMNOP
1MonthFeb-21Mar-21Apr-21May-21Jun-21Jul-21Aug-21Sep-21Oct-21Nov-21Dec-21Jan-22Future Value Data:May-21
2Investment Charges£11.64£11.68£11.73£11.77£11.82£11.86£11.91£11.95£12.00£12.04£12.09£12.13Value after Chgs£101,524.78
3Adviser Charges£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00
4Platform Service Fee£16.73£16.80£16.86£16.92£16.99£17.05£17.12£17.18£17.25£17.31£17.38£17.44
5Value After Charges£100,379.04£100,759.51£101,141.42£101,524.78£101,909.59£102,295.86£102,683.59£103,072.79£103,463.47£103,855.63£104,249.28£104,644.42
6MonthFeb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23
7Investment Charges£12.18£12.23£12.27£12.32£12.37£12.41£12.46£12.51£12.55£12.60£12.65£12.70
8Adviser Charges£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00
9Platform Service Fee£17.51£17.58£17.64£17.71£17.78£17.84£17.91£17.98£18.05£18.12£18.18£18.25
10Value After Charges£105,041.06£105,439.20£105,838.85£106,240.01£106,642.69£107,046.90£107,452.64£107,859.92£108,268.75£108,679.12£109,091.05£109,504.54
11MonthFeb-23Mar-23Apr-23May-23Jun-23Jul-23Aug-23Sep-23Oct-23Nov-23Dec-23Jan-24
12Investment Charges11.3916.113.7716.9418.4511.1816.5318.6516.7818.8310.2613.39
13Adviser Charges
14Platform Service Fee
15Value After Charges£117,717.93£136,807.31£130,669.80£117,880.36£136,455.97£114,753.42£105,385.99£130,446.97£133,322.74£133,493.10£149,550.71£114,084.63
Sheet2
Cell Formulas
RangeFormula
C11:M11,C6:M6,C1:M1C1=EDATE(B1,1)
B6,B11B6=EDATE(M1,1)


Code:
Sub MatchYrMo()
    Dim i As Long, lr As Long, col As Variant
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To lr Step 5
        col = Application.Match(Cells(1, 16), Range("A" & i & ":M" & i), 0)
        If Not IsError(col) Then
          Cells(2, 16) = Cells(i + 4, col).Value
          End
        Else
        End If
    Next i
End Sub
 
Upvote 0
That's brilliant - I'll give the macro a try. I also came up with another alternative, which is to add a column with a simple horizontal lookup for each date row, and return a nil value if the dates don't match the date in B12. That way the total of that column will match the value I'm looking for. What do you think?

Book1
ABCDEFGHIJKLMN
1MonthFeb-21Mar-21Apr-21May-21Jun-21Jul-21Aug-21Sep-21Oct-21Nov-21Dec-21Jan-22
2Investment Charges£11.64£11.68£11.73£11.77£11.82£11.86£11.91£11.95£12.00£12.04£12.09£12.13
3Adviser Charges£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00
4Platform Service Fee£16.73£16.80£16.86£16.92£16.99£17.05£17.12£17.18£17.25£17.31£17.38£17.44
5Value After Charges£100,379.04£100,759.51£101,141.42£101,524.78£101,909.59£102,295.86£102,683.59£103,072.79£103,463.47£103,855.63£104,249.28£104,644.420.00
6MonthFeb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23
7Investment Charges£12.18£12.23£12.27£12.32£12.37£12.41£12.46£12.51£12.55£12.60£12.65£12.70
8Adviser Charges£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00£0.00
9Platform Service Fee£17.51£17.58£17.64£17.71£17.78£17.84£17.91£17.98£18.05£18.12£18.18£18.25
10Value After Charges£105,041.06£105,439.20£105,838.85£106,240.01£106,642.69£107,046.90£107,452.64£107,859.92£108,268.75£108,679.12£109,091.05£109,504.5417.91
11
12Future value date:31/08/22
13Value after charges on that date:£17.91
Sheet1
Cell Formulas
RangeFormula
N5,N10N5=IFNA(HLOOKUP($B$12,B1:M5,4,0),0)
B13B13=SUM(N2:N10)
 
Upvote 0
You didn't want a helper column initially, but I think that's a good idea.
You can get the values for each row of totals through a macro so you don't have to copy and paste.

I took this approach:

Book3
ABCDEFGHIJKLMN
1MonthFeb-21Mar-21Apr-21May-21Jun-21Jul-21Aug-21Sep-21Oct-21Nov-21Dec-21Jan-22
2Investment Charges11.6411.6811.7311.7711.8211.8611.9111.951212.0412.0912.13
3Adviser Charges000000000000
4Platform Service Fee16.7316.816.8616.9216.9917.0517.1217.1817.2517.3117.3817.44
5Value After Charges100,379.04100,759.51101,141.42101,524.78101,909.59102,295.86102,683.59103,072.79103,463.47103,855.63104,249.28104,644.420
6MonthFeb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23
7Investment Charges12.1812.2312.2712.3212.3712.4112.4612.5112.5512.612.6512.7
8Adviser Charges000000000000
9Platform Service Fee17.5117.5817.6417.7117.7817.8417.9117.9818.0518.1218.1818.25
10Value After Charges105,041.06105,439.20105,838.85106,240.01106,642.69107,046.90107,452.64107,859.92108,268.75108,679.12109,091.05109,504.540
11MonthFeb-23Mar-23Apr-23May-23Jun-23Jul-23Aug-23Sep-23Oct-23Nov-23Dec-23Jan-24
12Investment Charges11.3916.113.7716.9418.4511.1816.5318.6516.7818.8310.2613.39
13Adviser Charges
14Platform Service Fee
15Value After Charges£117,717.93£136,807.31£130,669.80£117,880.36£136,455.97£114,753.42£105,385.99£130,446.97£133,322.74£133,493.10£149,550.71£114,084.63133493.1
16
17
18
19
20Nov-23
21£133,493.10
Sheet3
Cell Formulas
RangeFormula
N5,N15,N10N5=IFERROR(HLOOKUP($B$20,B1:M5,5,0),0)
B11B11=EDATE(M6,1)
C11:M11C11=EDATE(B11,1)
B21B21=SUM(N:N)
 
Upvote 0
Solution
I then did this macro:

Code:
Sub SumOnDate()
Dim i As Long, lr As Long, ival As Double
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To lr Step 5
    ival = WorksheetFunction.IfError(Application.HLookup(Range("B20"), Range("B" & i & ":M" & i + 4), 5, 0), 0)
    Cells(i + 4, 14) = ival
    Next i
    Cells(21, 2) = WorksheetFunction.Sum(Range("N:N"))
       
End Sub
 
Upvote 0
That's absolutely correct! I was thinking I would need to repeat all the info in the helper column. I prefer your suggestion to us IFERROR and have already used EDATE in the actual spreadsheet, so you've solved my problem!

Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

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