Combine "IF" with "VLOOKUP"

Mike Slattery

Board Regular
Joined
Dec 11, 2004
Messages
101
I currently have the following formula in cell (DH3) "=IFERROR(IF(DG3>0,CA3),"")"

It is checking to see if a cell (DG3) has a price in it greater than 0.

If it does then it produces the date that the price was produced from cell CA3.

I would like for this cell to check a list of dates and if the date is in the list keep the date visible, if the date is not in the list then display #N/A.

I know how to do this using VLOOKUP, but not how to combine the two into one cell.

The lookup range containing the list of dates is: (FT3:FT200)

Thanks, Michael
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi Jonmo1:

You formula ignores the check for a price in DG3 and does not provide an #N/A if there is no date present. I need the NA to plot this correctly in a chart.

You are doing the lookup on the list of dates (FT3:FT200) with the price field(DG3), not the date field(CA3). I really need to combine the two, checking to see if the price is greater than zero (0) and checking to see if the resulting date is in the list.

Thanks for you suggestion, Michael
 
Upvote 0
OK, I see it now..

Try

=IF(DG3>0,VLOOKUP(CA3,$FT$3:$FT$200,1,0))


Also, when you say you want it to return #N/A, are you meaning the usual error value #N/A from a vlookup formula, or a TEXT String of "N/A" ?
Your posts sound like you mean the error value #N/A..
 
Upvote 0
Hi:

The #N/A currently being utilized is generated from the formula that determines IF the current price (DG3) is at the top or bottom of a swing.

If both conditions are false then the cell displays "#NA" "=IF(CN3>CW3,CN3,IF(CW3>CN3,CW3,#N/A))"

Thanks Michael
 
Upvote 0
Ok, so it does sound like you mean the real #N/A error value then.

So this formula should do as you require
=IF(DG3>0,VLOOKUP(CA3,$FT$3:$FT$200,1,0))

If DG3 is > 0, then it checks if CA3 exists in FT3:FT200, if it does, then it shows that date, if not it returns the #N/A.
 
Upvote 0
Glad to help, thanks for the feedback.

I'll usually only use VBA if the task can't be completed by normal excel functions (formulas / pivot tables / filters etc.)
 
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,369
Members
448,888
Latest member
Arle8907

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