user3436187
user3436187

Reputation: 33

Vlookup in excel and vba

Below I have 2 files, 1 is a item master

File A

Article     Colour    Size    
ABC           Blue       M       
DEF           black      S      
GHI           Red        S      

File B - item master

Article     Colour    Size  
ABC           black      M      
DEF           black      S      
GHI           Red        L      

I would like to do a vlookup and create a exception column that will return:

Article     Colour    Size    Exception
ABC           Blue       M      Wrong Color
DEF           black      S      No exception
GHI           Red        L      Wrong Size

Is it possible to use VBA to do it?
Hope someone can help.Thanks!

EDIT 1

ITEM MASTER

Article     Colour    Size  
ABC           black      M   
ABC           blue       M
ABC           black      S   
DEF           black      S      
GHI           Red        L      

Upvotes: 0

Views: 141

Answers (1)

L42
L42

Reputation: 19737

Ok here is what I thought the best way.
I use Index and Match Function for this.
Assuming your data looks like this and you're checking exception referenced to another open file.

First, set-up a Match Function Helper Column using this formula:
=MATCH(A2,[Book2]Sheet1!$A:$A,0)

enter image description here

Second, use Index Function with If to determine exception. Use below formula:
Edit1: =IF(INDEX([Book2]Sheet1!$B:$B,E2)=B2,IF(INDEX([Book2]Sheet1!$C:$C,E2)=C2,"No Exception","Wrong Size"),IF(INDEX([Book2]Sheet1!$C:$C,E2)=C2,"Wrong Color","Both Exception"))

Index Funtion

This is assuming your Item Master data is in Book2.
Recalculation speed is fast using this formula, although I cannot give you exact numbers.
Hope this somehow helps you.

Upvotes: 1

Related Questions