Copy Match from 2 different Workbooks & Copy to worksheet in vba macro

ucsutah1

Board Regular
Joined
Jan 17, 2011
Messages
56
Hi,

I just need a little bit of help with this code.

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 on the code, but the difference is if column I (price) workbook datafeed.xlsx is the same as price on column J (seller price) workbook result.xlsx. Then copy results (only the same & not different) to new sheet named "same price", However, I need to have B column copied over as well as the same price. FYI the b column is sku and I need to know what price it is referring to based off the sku. So 2 things copied the sku and the same price onto a new worksheet called "same price" in result.xlsx.

If you need examples of workbooks I can provide those?


Code:
    Dim w1 As Worksheet, w2 As Worksheet    Dim c As Range, FR As Long


    Set w1 = Workbooks("datafeed.xlsm").Sheets("datafeed")
    Set w2 = Workbooks("result.xlsx").Sheets("Sheet 1")
    
    For Each c In w1.Range("b2", w1.Range("b" & Rows.Count).End(xlUp))
        FR = 0
        On Error Resume Next
        FR = Application.Match(c, w2.Columns("b"), 0)
        On Error GoTo 0
        If FR <> 0 Then w2.Range("J" & FR).Value = c.Offset(, 7)


Next c

thanks for your help
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,215,039
Messages
6,122,799
Members
449,095
Latest member
m_smith_solihull

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