compare between two sheets and replace and arrange with empty cells

Hasson

Active Member
Joined
Apr 8, 2021
Messages
401
Office Version
  1. 2016
Platform
  1. Windows
Hi
I want matching sheet MATCH with sheet REPORT based on column B between two sheets if they are matched then should replace items in column C for sheet MATCH based on sheet REPORT and arrange data for sheet MATCH based on column B for sheet REPORT and any items for column C contains empty cell for column B in sheet MATCH should put in last row .
s.xlsx
ABCDEF
1ITEMCODEDESCIBEQTYUNIT PRICETOTAL
21ATR-A100CLA1 12320020040000
32ATR-A105CLA2 VBG L1/m30030090000
43ATR-A106CLA3-100400400160000
54ATR-A103CLA41500500250000
65CLA122211242
76ATR-A104CLA5600600360000
87CLA101212144
98ATR-A101M230700700490000
109ATR-A102CLA7800800640000
1110ATR-A109CLA8900900810000
1211ATR-A110CLA9 N100010001000000
1312ATR-A111CLA10110011001210000
1413ATR-A112LVD120012001440000
1514ATR-A113CLA12130013001690000
1615ATR-A114CLA13140014001960000
1716ATR-A115CLA14 SS230150015002250000
1817ATR-A114CLA15160016002560000
1918ATR-A115CLA16170017002890000
2019ATR-A116CLA17180018003240000
2120ATR-A117RRSDF190019003610000
match
Cell Formulas
RangeFormula
F2:F21F2=D2*E2


s.xlsx
ABC
21ATR-A100CLA1 23M-1
32ATR-A101CLA2 VBG L
43ATR-A102CLA3
54ATR-A103CLA4
65ATR-A104CRET3
76ATR-A105M230
report



result
s.xlsx
ABCDEF
1ITEMCODEDESCIBEQTYUNIT PRICETOTAL
21ATR-A100CLA1 23M-120020040000
32ATR-A101CLA2 VBG L700700490000
43ATR-A102CLA3800800640000
54ATR-A103CLA4500500250000
65ATR-A104CRET3600600360000
76ATR-A105M23030030090000
87ATR-A106CLA3-100400400160000
98ATR-A109CLA8900900810000
109ATR-A110CLA9 N100010001000000
1110ATR-A111CLA10110011001210000
1211ATR-A112LVD120012001440000
1312ATR-A113CLA12130013001690000
1413ATR-A114CLA13140014001960000
1514ATR-A115CLA14 SS230150015002250000
1615ATR-A114CLA15160016002560000
1716ATR-A115CLA16170017002890000
1817ATR-A116CLA17180018003240000
1918ATR-A117RRSDF190019003610000
2019CLA122211242
2120CLA101212144
result
Cell Formulas
RangeFormula
F2:F21F2=D2*E2



thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Try this:

VBA Code:
Sub comparesheets()
  Dim f As Range, c As Range
  Dim lr As Long
  
  With Sheets("RESULT")
    Sheets("MATCH").Cells.Copy .Range("A1")
    lr = .Range("A" & Rows.Count).End(3).Row
    .Range("B1:F" & lr).Sort key1:=.Range("B1"), order1:=1, Header:=xlYes
    For Each c In .Range("B2:B" & lr)
      If c.Value <> "" Then
        Set f = Sheets("REPORT").Range("B:B").Find(c.Value, , xlValues, xlWhole, , , False)
        If Not f Is Nothing Then
          .Range("C" & c.Row).Value = f.Offset(, 1).Value
        End If
      End If
    Next
  End With
End Sub
 
Upvote 0
awesome!
this is really helpful . just question can I replace column C in sheet match from column C sheet report based on matching column B between two sheets , sometimes there is different items in column C between two sheets for the same items for column B betwwen two sheets.
for instance sheet match,report column B=ATR-100 but column C in sheet match=CL2-23A1 , column C for sheet report= CLA2-23A1 then item in column C for sheet match =CLA2-23A1.
the rsult should be in sheet MATCH
thanks again
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

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