VLookups

Anna

New Member
Joined
Apr 23, 2002
Messages
2
I have a table of data (product codes), sorted ascendingly and sales units. I am using this to complete a look-up in another work sheet which lists these product codes, but also product codes that do not exist in the data range. I need to see sales units for the codes that are in both worksheets and zeros for those that aren't.
However, for codes which cannot be found in the range, the lookup function either gives me the sales unit for the product code closest to it, or if i use the 'false' wording at the end of the function, it gives me an #n/a.
Can anyone advise on how to either use the vlookup function to make any values it can't find zero, or to then, in the next column, use an IF function to change any values that aren't numbers (e.g. #n/a) to zero?

Help!

Thanks

Anna
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
If A2:A100 in sheet 1 contents product codes, B2:B100 in sheet 1 the sales units, A2:A100 in sheet 2 the same product codes as in sheet 1 but also product codes wich don't exist in sheet 1, enter in C2 of sheet 2:
=IF(ISNA(VLOOKUP($A2,SHEET1!$A$2:$B$100,1,FALSE)),0,VLOOKUP($A2,SHEET1!$A$2:$B$100,2,FALSE))
Copy this formula down in column C of sheet 2.
This message was edited by Albert 1 on 2002-04-24 04:39
This message was edited by Albert 1 on 2002-06-01 02:57
 
Upvote 0
On 2002-04-24 02:27, Anna wrote:
I have a table of data (product codes), sorted ascendingly and sales units. I am using this to complete a look-up in another work sheet which lists these product codes, but also product codes that do not exist in the data range. I need to see sales units for the codes that are in both worksheets and zeros for those that aren't.
However, for codes which cannot be found in the range, the lookup function either gives me the sales unit for the product code closest to it, or if i use the 'false' wording at the end of the function, it gives me an #n/a.
Can anyone advise on how to either use the vlookup function to make any values it can't find zero, or to then, in the next column, use an IF function to change any values that aren't numbers (e.g. #n/a) to zero?

Help!

Thanks

Anna

Lets say that the product codes and sales units data are in A2:B100 (excuding labels) in worksheet 1 whose name is, say, Data.

From a different worksheet, use:

=IF(COUNTIF(Data!$A$2:$A$200,C2),VLOOKUP(C2,Data!$A$2:$B$100,2,0),0)

Aladin
 
Upvote 0

Forum statistics

Threads
1,213,559
Messages
6,114,302
Members
448,564
Latest member
ED38

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