Index and If statement assistance

Killsek

New Member
Joined
Mar 1, 2016
Messages
6
Hello all,
I am wondering if someone would be able to assist me in getting this Index and If statement to work properly or if there is a better way to do it.
I have two worksheets CR and October, on the CR sheet in Column A is a list of categories (Utilities, Auto Loan, CC, Grocery, etc) and then starting with column D it just shows if its a credit or debit and then continues through like a check register. Now on the October tab in cell H1 you type in the month number (10 in this case) and it will give you all of the listings from CR that is within the month of October and its information based on that entry. ALL OF THIS WORKS FINE !!!
What I cannot get to work is I only want items to show on the October tab if it is in a range from the CR tab in column A10-A12 (and maybe more rows if I add additional categories) so any credits or items other than the cell range A10:A12 then it show up. I added the TRUE/FALSE column to show if it was in the A10:A12 range when I was trying different ways but still couldn't get it to work.

Any ideas would be greatly appreciated..

CR.xlsx
ABCDEFGHIJK
1GASC/DDatePayeeCategoryAmountIn A10-A12
2OtherDebit10/1/2022Capital OneCC$ 225.00TRUE
3EntertainmentDebit10/1/2022Winn DixieGrocery$ 50.00FALSE
4GroceryDebit9/25/2022DiscoverAuto Loan$ 75.00TRUE
5Debit10/2/2022JEAUtility$ 15.00TRUE
6Debit10/3/2022RacetrackGAS$ 38.00FALSE
7Debit10/4/2022BojanglesOther$ 60.00FALSE
8Debit10/30/2022MastercardCC$ 61.00TRUE
9Debit9/6/2022MarshallsOther$ 62.00FALSE
10Auto LoanCredit10/7/2022PaycheckDeposit$ 5.00FALSE
11CC
12Utility
13
14
CR
Cell Formulas
RangeFormula
J2:J10J2=SUMPRODUCT(--ISNUMBER(SEARCH($A$10:$A$12,$G2)))>0




Cell Formulas
RangeFormula
A2:A10A2=IFERROR( INDEX(CR!$E$2:$I$3000, SMALL( IF((MONTH(CR!$E$2:$E$3000)=$H$1)*(CR!$E$2:$E$3000>1), ROW(CR!$E$2:$E$3000) - ROW(CR!$E$2)+1 ),ROW(1:1) ),1 ),"" )
B2:B10B2=IFERROR( INDEX(CR!$E$2:$I$3000, SMALL( IF((MONTH(CR!$E$2:$E$3000)=$H$1)*(CR!$E$2:$E$3000>1), ROW(CR!$E$2:$E$3000) - ROW(CR!$E$2)+1 ),ROW(1:1) ),2 ),"" )
C2:C10C2=IFERROR( INDEX(CR!$E$2:$I$3000, SMALL( IF((MONTH(CR!$E$2:$E$3000)=$H$1)*(CR!$E$2:$E$3000>1), ROW(CR!$E$2:$E$3000) - ROW(CR!$E$2)+1 ),ROW(1:1) ),3 ),"" )
D2:D10D2=IFERROR( INDEX(CR!$E$2:$I$3000, SMALL( IF((MONTH(CR!$E$2:$E$3000)=$H$1)*(CR!$E$2:$E$3000>1), ROW(CR!$E$2:$E$3000) - ROW(CR!$E$2)+1 ),ROW(1:1) ),4 ),"" )
E2:E8E2=IFERROR( INDEX(CR!$E$2:$I$3000, SMALL( IF((MONTH(CR!$E$2:$E$3000)=$H$1)*(CR!$E$2:$E$3000>1), ROW(CR!$E$2:$E$3000) - ROW(CR!$E$2)+1 ),ROW(1:1) ),5 ),"" )
Press CTRL+SHIFT+ENTER to enter array formulas.
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
What version of Excel are you using? Please update your profile to show that, as preferred solutions can depend on the version.
 
Upvote 0
Assuming that you have an up to date version of excel, this will do what you want it to without the need for the helper column (column J) in the CR sheet.
Book1
ABCDEFGH
1DatePayeeCategory Amount DepositMonth #10
210/1/2022Capital OneCC$225.00$0.00
310/1/2022Winn DixieGrocery$50.00$0.00
410/2/2022JEAUtility$15.00$0.00
510/3/2022RacetrackGAS$38.00$0.00
610/4/2022BojanglesOther$60.00$0.00
710/30/2022MastercardCC$61.00$0.00
Sheet17
Cell Formulas
RangeFormula
A2:E7A2=FILTER(CR!E2:I10,ISNUMBER(MATCH(CR!$G$2:$G$10,CR!$A$1:$A$12,0))*(MONTH(CR!$E$2:$E$10)=$H$1))
Dynamic array formulas.
 
Upvote 0
Upvote 0
If you do have Excel 365 functions and you try Jason's solution---and if I understand correctly that you want to include only categories shown in A10:A12---then change CR!$A$1 in Jason's formula to CR!$A$10. That part of the formula describes categories that are to be matched.
 
Upvote 0
Cheers, Kirk! I misread A10 as A1 in the question.

Little tip for your method, if you use the entire column for the index range you can omit the row adjustments from the array and reduce calculation overheads.
Excel Formula:
=IFERROR(INDEX(CR!$E:$I,AGGREGATE(15,6,ROW(CR!$E$2:$E$3000)/((MONTH(CR!$E$2:$E$3000)=$H$1)*ISNUMBER(MATCH(CR!$G$2:$G$10,CR!$A$10:$A$12,0))),ROWS($1:1)),COLUMNS($A:A)),"")
The other option to reduce calculation overheads with this method is to make the adjustment outside of the array so that it only needs to make 2 single calculations instead of the ~6000 when working with the array elements directly.
Excel Formula:
=IFERROR(INDEX(CR!$E$2:$I$3000,AGGREGATE(15,6,ROW(CR!$E$2:$E$3000)/((MONTH(CR!$E$2:$E$3000)=$H$1)*ISNUMBER(MATCH(CR!$G$2:$G$10,CR!$A$10:$A$12,0))),ROWS($1:1))-ROW(CR!$E$2)+1,COLUMNS($A:A)),"")
I did some timed tests on the different methods with some other forum members a couple of years ago, from what I can remember the second method above was slightly faster than the first one (although the first is my personal preference for simplicity) with both offering a substantial improvement over the traditional method.
 
Upvote 0
Solution
Thanks, Jason...I appreciate the tip. I hadn't thought about either of those approaches. I'm accustomed to forming the row-indexing array {1;2;3;...} with a construction like (ROW(CR!$E$2:$E$3000) - ROW(CR!$E$2)+1), but it's not exactly easy to read and often leaves others wondering what it does. I like the first option too for simplicity and readability.
 
Upvote 0
Thank you Jason and Kirk, you guys have saved me so much time, although I gave it valiant effort I just couldn't get it. I did use Jason's 1st solution as it was the best option for me to utilize.

You guys rock, thanks again !
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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