Two If(And statements with vlookups only returning the first value

ab3g1nner

New Member
Joined
Nov 29, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
=IFERROR(IF(AND('Transaction Summary Report'!G1829="ACTIVE",'Transaction Summary Report'!C1829=$B$2),VLOOKUP('Transaction Summary Report'!A1829,'LB Account Map'!A:B,2,0),IFERROR(IF(AND('Transaction Summary Report'!G1829="ACTIVE",'Transaction Summary Report'!C1829=$B$2),VLOOKUP('Transaction Summary Report'!B1829,'LB Account Map'!A:B,2,0),""),"")),"")

Need the ands, then to lookup A1829 or if in the lookup A1829 cannot be found, to lookup B1829. I've switched around A1829 to lookup in the first statement, then B1829 to look up first. Whichever lookup is in the first section of the if(and(lookup, is what is returned. Broke these up in separate parts and was able to return the proper value using the if(and(lookup to A1829, then separately B1829 and works fine. Not really familiar with other formulas other than iferror, if, and, and vlookup. Saw a post somewhere for switch, but haven't explored that yet.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I FIGURED OUT MY OWN PROBLEM!!! It was only returning the first response because both transaction types, in (A1829 & B1829) had the same label I was using to Vlookup in G1829 (ACTIVE). I modified it to where all items in column A = ACTIVE in G, and all items in column B = PP ACTIVE! Genius!!
 
Upvote 0
=IFERROR(IF(AND('Transaction Summary Report'!G6000="ACTIVE",'Transaction Summary Report'!C6000=$B$2),VLOOKUP('Transaction Summary Report'!A6000,'LB Account Map'!A:B,2,0),IFERROR(IF(AND('Transaction Summary Report'!G6000="PP ACTIVE",'Transaction Summary Report'!C6000=$B$2),VLOOKUP('Transaction Summary Report'!B6000,'LB Account Map'!A:B,2,0),""),"")),"")

Therefore, this ^^ was the final working formula!
 
Upvote 0
Solution
If you want, your formula ...
Excel Formula:
=IFERROR(IF(AND('Transaction Summary Report'!G6000="ACTIVE",'Transaction Summary Report'!C6000=$B$2),VLOOKUP('Transaction Summary Report'!A6000,'LB Account Map'!A:B,2,0),IFERROR(IF(AND('Transaction Summary Report'!G6000="PP ACTIVE",'Transaction Summary Report'!C6000=$B$2),VLOOKUP('Transaction Summary Report'!B6000,'LB Account Map'!A:B,2,0),""),"")),"")
... could be shortened a bit by using the LET function like this
Excel Formula:
=LET(TSR,'Transaction Summary Report'!A6000:G6000,LBAB,'LB Account Map'!A:B,IFERROR(IF(AND(INDEX(TSR,7)="ACTIVE",INDEX(TSR,3)=$B$2),VLOOKUP(INDEX(TSR,1),LBAB,2,0),IFERROR(IF(AND(INDEX(TSR,7)="PP ACTIVE",INDEX(TSR,3)=$B$2),VLOOKUP(INDEX(TSR,2),LBAB,2,0),""),"")),""))
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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