Match 2 columns from 2 different workbooks, if no match then put 0 in another column?

ucsutah1

Board Regular
Joined
Jan 17, 2011
Messages
56
Hi,

I just need a little bit of help with this code. I just about have it but not quite.

I need to match 2 different columns in 2 different workbooks. I need to match column b (sku) on workbook datafeed.xlsx to workbook result.xlsx on column b (sku), as shown in the code.
If no match from result.xlsx from workgroup datafeed.xlsx then I need it to put a number 0 in column/row ab2 which is offset to column 26 from b2.

So what I am thinking is offset 11 should be 26 but a value of 0?

thanks

If you need examples of workbooks I can provide those?

Code:
[/COLOR]Set w3 = Workbooks("datafeed.xlsx").Sheets("datafeed")    Set w4 = Workbooks("result.xlsx").Sheets("Sheet 1")
    
    For Each z In w3.Range("b2", w3.Range("b" & Rows.Count).End(xlUp))
        XR = 0
        On Error Resume Next
        XR = Application.Match(z, w4.Columns("b"), 0)
        On Error GoTo 0
        If XR <> 0 Then w4.Range("o" & XR).Value = z.Offset(, 11)

    Next z[COLOR=#333333]
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Cross posted https://www.ozgrid.com/forum/forum/...ooks-if-no-match-then-put-0-in-another-column

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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