What formula do i need vlookup to index match or something else?

Dazzybeeguy

Board Regular
Joined
Jan 6, 2022
Messages
111
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
I need a formula that if cell c4 is populated than it looks up the value in Cell C4 in worksheet 2 (called Data2) say column A:A and I want it to give the value in worksheet 2 column M:M, if the value is not in the Data2 worksheet I want it to return "Ref Not found"

So a lookup works fine, however if the value in C4 is not there it gives #N/A

So both of the formulas I tried give the #N/A result if there is a value in C4 but it is not in the Data2 worksheet =IF(C4>0,VLOOKUP(D4,Data2!A2:N9999,14,FALSE),"")

I tried =INDEX(Data2!M:M,MATCH(D4,Data2!A:A,0))&" Last Comment - "&INDEX(Data2!N:N,MATCH(D4,Data2!A:A,0)) but still get #N/A if the value in C4 is not in the other worksheet

Thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Both VLOOKUP and INDEX should result in #N/A if the target is not found. If you want it to return something else, wrap your lookup (or index,match,match) in IFERROR(). For example, assuming your concatenated INDEX formulas work when the target value is found:
Excel Formula:
=IFERROR(INDEX(Data2!M:M,MATCH(D4,Data2!A:A,0))&" Last Comment - "&INDEX(Data2!N:N,MATCH(D4,Data2!A:A,0)),"Ref Not found")
 
Upvote 0
If you are using your 365 version of Excel rather than the 2010 you can use the more specific IFNA function rather than the more general IFERROR function (which may hide some other errors that you might want to know about). You could also save having to to MATCH D4 in column A twice & just do it once.

Excel Formula:
=LET(m,MATCH(D4,Data2!A:A,0),IFNA(INDEX(Data2!M:M,m)&" Last Comment - "&INDEX(Data2!N:N,m),"Ref not found"))
 
Upvote 0
Both VLOOKUP and INDEX should result in #N/A if the target is not found. If you want it to return something else, wrap your lookup (or index,match,match) in IFERROR(). For example, assuming your concatenated INDEX formulas work when the target value is found:
Excel Formula:
=IFERROR(INDEX(Data2!M:M,MATCH(D4,Data2!A:A,0))&" Last Comment - "&INDEX(Data2!N:N,MATCH(D4,Data2!A:A,0)),"Ref Not found")
The only issue is if C4 is empty it returns the "Ref not found" when I want it to return no value. I can use the formula in say cell A1 then use formula =IF(C4>0,A1,"")
 
Upvote 0
If you are using your 365 version of Excel rather than the 2010 you can use the more specific IFNA function rather than the more general IFERROR function (which may hide some other errors that you might want to know about). You could also save having to to MATCH D4 in column A twice & just do it once.

Excel Formula:
=LET(m,MATCH(D4,Data2!A:A,0),IFNA(INDEX(Data2!M:M,m)&" Last Comment - "&INDEX(Data2!N:N,m),"Ref not found"))
The only issue is if C4 / D4 is empty it returns the "Ref not found" when I want it to return no value. I can use the formula in say cell A1 then use formula =IF(C4>0,A1,"")
 
Upvote 0
I think I follow you. Please give this a try:
Excel Formula:
=IF(D4="","",IFERROR(VLOOKUP(D4,Data2!A:N,14,FALSE),"Ref Not Found"))
 
Upvote 0
The only issue is if C4 / D4 is empty ..
One of your post #1 formulas had =IF(C4>0,... but the other didn't, so a bit hard to know exactly what you did want. Still guessing but could it be this?

Excel Formula:
=IF(AND(C4>0,D4<>""),LET(m,MATCH(D4,Data2!A:A,0),IFNA(INDEX(Data2!M:M,m)&" Last Comment - "&INDEX(Data2!N:N,m),"Ref not found")),"")
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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