Index two columns, return associated cell.

  • Thread starter Thread starter Legacy 287428
  • Start date Start date
L

Legacy 287428

Guest
Hello there!

Been a while since I have posted as the forums have been so helpful. I am working on a summary sheet for a personal finance sheet where the data I am pulling from has 7 columns, and as many rows are in a year. Essentially what I am trying to have the cell in question do is query Column A (year), and Column B (week), locate what row that is, and I want one cell to return "Expenditures to date" (Column F), then the second cell returns "Income to date" (Column G).

The example below is a simplified table of what I am using - If I am trying to pull the Annual Cumulative Credit for week 29 of 2020 it should return 1200 even though there are other week 29's in the table.

I had used the following function to return the result moderately successfully, but when I tried linking the data to the cells in the other work sheet I keep getting #N/A. What worked is (H1 is the year, H2 is the week): =INDEX(G2:G4,MATCH(H1&H2,A2:A4&B2:B4,0)) followed by CTRL+SHIFT+ENTER

I am using Windows 10, and Excel 2016 and cant use XLOOKUP unfortunately.


YearWeekWeekly DebitWeekly CreditAnnual Cumulative DebitCumulative Debit Adjusted PositiveAnnual Cumulative Credit
2017292050-500500800
2018294055-600600900
2019292560-6006001000
2020296065-7007001200
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Here is one approach:
Book4
ABCDEFGHI
1YearWeekWeekly DebitWeekly CreditAnnual Cumulative DebitCumulative Debit Adjusted PositiveAnnual Cumulative Credit2020<-- Year
22017292050-50050080029<-- Week
32018294055-600600900700<-- Expenditures to Date
42019292560-60060010001200<-- Income to Date
52020296065-7007001200
Sheet1
Cell Formulas
RangeFormula
H3H3=SUMPRODUCT(($A$2:$A$5=$H$1)*($B$2:$B$5=$H$2),$F$2:$F$5)
H4H4=SUMPRODUCT(($A$2:$A$5=$H$1)*($B$2:$B$5=$H$2),$G$2:$G$5)
 
Upvote 0
Here is one approach:
Book4
ABCDEFGHI
1YearWeekWeekly DebitWeekly CreditAnnual Cumulative DebitCumulative Debit Adjusted PositiveAnnual Cumulative Credit2020<-- Year
22017292050-50050080029<-- Week
32018294055-600600900700<-- Expenditures to Date
42019292560-60060010001200<-- Income to Date
52020296065-7007001200
Sheet1
Cell Formulas
RangeFormula
H3H3=SUMPRODUCT(($A$2:$A$5=$H$1)*($B$2:$B$5=$H$2),$F$2:$F$5)
H4H4=SUMPRODUCT(($A$2:$A$5=$H$1)*($B$2:$B$5=$H$2),$G$2:$G$5)
That worked well, thank you very much for the suggestion! I tried something similar earlier, but forgot to put parenthesis around the Year and Month queries.
 
Upvote 0
Using a more efficient function that many people seem to have forgotten about recently :oops:

=SUMIFS(F2:F5,A2:A5,H1,B2:B5,H2)
 
Upvote 0
You're welcome...we're glad to help. Jason's suggestion is even better...more compact and efficient. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,128
Members
453,021
Latest member
Justyna P

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