Match & paste name and description based on SKU from sheet 2 to sheet 1

megamiska

New Member
Joined
Aug 28, 2020
Messages
6
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I need your help :)

I want to update products names and descriptions, so I need to match product names and product descriptions from sheet 2 (source) to sheet 1 based on SKU.

Example:

Sheet 1 (Data):

SkuStandard name enStandard description en
A4308
11383

Sheet 2 (List1)
SkuStandard name enStandard description en
A4308TV coax plug<br>metal typeMale coax plug<br />Connects with all coax cable<br />Metal type<br /><br />
11383TV coax plug<br>90°<br>short-type<ul class="piul">
<li>90°</li>
<li>Short type</li>
<li>plastic house</li>
</ul>


How can I do this?

Please check images.

Thanks in advance!
 

Attachments

  • SKU2.png
    SKU2.png
    36.3 KB · Views: 7
  • SKU.png
    SKU.png
    30.1 KB · Views: 8

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
copy to module1

VBA Code:
Sub t()
Dim sh1 As Worksheet, sh2 As Worksheet, c As Range, fn As Range
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
    With sh1
        For Each c In .Range("B2", .Cells(Rows.Count, 2).End(xlUp))
            Set fn = sh2.Range("A:A").Find(c.Value, , xlValues, xlWhole)
                If Not fn Is Nothing Then
                    c.Offset(, 2) = fn.Offset(, 1).Value
                    c.Offset(, 3) = fn.Offset(, 2).Value
                End If
               Set fn = Nothing
        Next
    End With
End Sub
 
Upvote 0
copy to module1

VBA Code:
Sub t()
Dim sh1 As Worksheet, sh2 As Worksheet, c As Range, fn As Range
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
    With sh1
        For Each c In .Range("B2", .Cells(Rows.Count, 2).End(xlUp))
            Set fn = sh2.Range("A:A").Find(c.Value, , xlValues, xlWhole)
                If Not fn Is Nothing Then
                    c.Offset(, 2) = fn.Offset(, 1).Value
                    c.Offset(, 3) = fn.Offset(, 2).Value
                End If
               Set fn = Nothing
        Next
    End With
End Sub

Thanks, where exactly should I copy this code? How can I run this to match cells? Sorry, I'm not familliar with excel...
 
Upvote 0
To test the code, make a copy of your file using a different workbook name. Save that file as a macro enabled workbook (.xlsm). Open the vb editor (Alt + F11) and if the large editor pane is dark then click 'Insert' on the editor tool bar, then click 'Module' in the pop up menu. Module1 should appear in the 'Projects' pane at upper left in the editor window. When the large pane brightens, you can copy and paste the code into that code pane. To run the code, close the editor and then press Alt+ F8 to bring up the Macro dialog box. Click on the macro name once then click 'Run'. If the code runs without error, you can then follow the same procedure to install it into your original file. If there is an error message, note the meessage, click the 'Debug' button and note the line of code that is highlighted. Post those two pieces of information back to this thread so we can look at it and try to fix it. If the code satisfies your original issue, then please let us know that also. Don't forget to dispense with the copy of your file when finished.
 
Upvote 0
Thanks for explanation!

I get this error: Set sh1 = Sheets("Sheet1")
 
Upvote 0
Thanks for explanation!

I get this error: Set sh1 = Sheets("Sheet1")
If you do not have worksheets named"Sheet1" and/or "Sheet2" then simply substitute the actual names of the applicable sheets in these two statements

Rich (BB code):
Set sh1 = Sheets("Sheet1")
Set sh2 = Sheets("Sheet2")
 
Upvote 0
Maybe someone in your workplace can help you with it.
Regards, JLG
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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