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: 4
  • SKU.png
    SKU.png
    30.1 KB · Views: 4

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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
 

megamiska

New Member
Joined
Aug 28, 2020
Messages
6
Office Version
  1. 2019
Platform
  1. Windows
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...
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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.
 

megamiska

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

ADVERTISEMENT

Thanks for explanation!

I get this error: Set sh1 = Sheets("Sheet1")
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows

ADVERTISEMENT

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")
 

megamiska

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

I try, but get all messed up in file :/
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
Maybe someone in your workplace can help you with it.
Regards, JLG
 

Forum statistics

Threads
1,136,864
Messages
5,678,214
Members
419,751
Latest member
TryingtoLearnVBA

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
Top