I have an IF(ISNA statement that I can't get inside an IF statement

netrixuser

Board Regular
Joined
Jan 21, 2019
Messages
77
Office Version
  1. 365
Platform
  1. Windows
Hi all, I have the following piece of code that I found on this site (from Joe [can't remember surname, sorry - thanks again !])

Range("U2").Formula = "=IF(ISNA(VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)),"""",VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE))"
Range("U2", "U" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown

I've added a couple of lines to format a column for Date, so it now looks like this:

'Bring in :Last mobile media from Fonetic report
Sheets("Accsys Report").Select
Columns("U:U").Select
Selection.NumberFormat = "[$-x-sysdate]dddd, mmmm dd, yyyy"
Range("U2").Formula = "=IF(ISNA(VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)),"""",VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE))"
Range("U2", "U" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown

So the above successfully adds the formula to the top cell in column U and then copies (fills) down to where the last cell has data in in column A. I copied the formula from another site - I normally just use Vlookup but would get N/A in what should be a blank cell, the above gives me blank cells where there is no match.

I now need the formula to only run if the corresponding cell in column S has the word " Yes" in it - I thought it would be as simple as enclosing the above in another =IF statement

I tried just adding the formula to Cell U2 before entering it into the script - this is what I have tried so far:

=if(S2="Yes",=IF(ISNA(VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)),"",VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE))","Not Recorded")
=if(S2="Yes",(=IF(ISNA(VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)),"",VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)))","Not Recorded")​

I also tried a "normal" vlookup inside an IF=

=If(S2="Yes",=Vlookup(B2,'Fonetic Report'!B:G,5,FALSE)),"Not Recorded")
=If(S2="Yes",(=Vlookup(B2,'Fonetic Report'!B:G,5,FALSE)),"Not Recorded)

None of the above work for me - I must be overlooking something obvious methinks..... but what ?

Thanks in advance for any help !

Regards
Netrixuser
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try:

=IF(S2="Yes",IF(ISNA(VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)),"",VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)),"Not Recorded")
 
Upvote 0
Solution
If your excel version isnt old you could use IFERROR.

=IF(S2="Yes",IFERROR(VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE),""),"Not Recorded")
 
Upvote 0
Try:

=IF(S2="Yes",IF(ISNA(VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)),"",VLOOKUP(B2,'Fonetic Report'!B:G,5,FALSE)),"Not Recorded")

Thank you Mr Fish !! works a treat, I'll try your other suggestion once I have everything working
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
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