VBA vlookup without N/A in the following code

Philip00

New Member
Joined
Aug 16, 2017
Messages
37
Hello All,

I have a working macro with vlookup function and i was able to make it work that if the cell is empty then the result cell is empty as well but if the function does not find the reference cell then it gives me N/A.

Can somebody help me that instead of N/A i got blank cells as well?

Range("AQ2:AQ" & LastRow).FormulaR1C1 = "=IF(VLOOKUP(RC[-41],'" & ActiveSheet.Previous.Name & "'!R1C47:R185C2,42,0)="""","""",VLOOKUP(RC[-41],'" & ActiveSheet.Previous.Name & "'!R1C47:R185C2,42,0))"

Thank You in Advance,
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try wrapping an IFERROR around it:

Code:
Range("AQ2:AQ" & LastRow).FormulaR1C1 = "=IF(IFERROR(VLOOKUP(RC[-41],'" & ActiveSheet.Previous.Name & "'!R1C47:R185C2,42,0),"""")="""","""",VLOOKUP(RC[-41],'" & ActiveSheet.Previous.Name & "'!R1C47:R185C2,42,0))"

But I guess that's also the same as:

Code:
Range("AQ2:AQ" & LastRow).FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-41],'" & ActiveSheet.Previous.Name & "'!R1C47:R185C2,42,0),"""")"

WBD
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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