Forum Discussion

vinedancer's avatar
vinedancer
Copper Contributor
Sep 30, 2022

Using IF and VLOOKUP together

I have a workbook where the first sheet has dates in the heading and the data for those columns is on another sheet. I want to combine an If statement to pick up the date, then lookup the items (say Food purchases) and return either column 2, 3 or 4 depending on the date heading.

 

Not sure of the exact syntax but tried all sorts to get the IF and VLOOKUP to work together.

 

=IF($J$5='P&L25.9 '!$C$4,"vlookup,'2023'!A6,'P&L25.9 '!$a$6:$Z$60,4",0)

This statement isn't working.

 

Thanks 🙂

2 Replies

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    vinedancer This syntax should work, though I can't test it if returns the desired result.

     

    =IF($J$5='P&L25.9 '!$C$4,VLOOKUP('2023'!A6,'P&L25.9 '!$A$6:$Z$60,4,0),"-")

     

    It performs the VLOOKUP when the criteria is met or "-" if it is not)

    • vinedancer's avatar
      vinedancer
      Copper Contributor
      OMG you're a genius! Thank you, it worked 🙂

Resources