Vlookup Alternative

helpexcel

Well-known Member
Joined
Oct 21, 2009
Messages
656
Hi - I'm using the code below to lookup data in Ws2 and place it in Ws1. Currently if the value in Ws1 Column A isn't found in Ws2 Column E it will put a "N" in Column P. How do I tweak it so that it only changes the cells in Column P when there is a match between Ws1 Column P and Ws2 Column E?

thanks!

Code:
 With CreateObject("scripting.dictionary")      
.CompareMode = 1
      For Each Cl In Ws2.Range("E45", Ws2.Range("E" & Rows.Count).End(xlUp))
         .Item(Cl.Value) = Cl.Offset(, 16).Value
      Next Cl
      For Each Cl In ws1.Range("A11", ws1.Range("A" & Rows.Count).End(xlUp))
         Cl.Offset(, 15).Value = IIf(UCase(.Item(Cl.Value)) = "SOLD OUT", "Y", "N")
      Next Cl
   End With
 
Last edited:

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
How about
Code:
      For Each Cl In ws1.Range("A11", ws1.Range("A" & Rows.Count).End(xlUp))
         If .Exists(Cl.Value) Then Cl.Offset(, 15).Value = IIf(UCase(.Item(Cl.Value)) = "SOLD OUT", "Y", "N")
      Next Cl
 
Upvote 0
How have you changed your original code?
 
Upvote 0
Can you please post you're modified code?
 
Upvote 0
Just figured it out...I defined Cl as C1, they look alike in the coding.
 
Last edited:
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

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