replace item for range with item for Table based on column

abdo meghari

Active Member
Joined
Aug 3, 2021
Messages
465
Office Version
  1. 2019
Hello
here is data in sheet1 as TABLE not range.
TABLE.xlsm
ABC
1ITEMBRANDQTY
21T01 185/65 R15188
321200R20 G580 JAP102
431200R20 R187 JAP133
541200R24 G580 JZ0
651300R22.5 R187 JAP147
761400R20 R180 JAP97
87175/65R14 B25A32 THI150
98175/70R13 EP150 THI4
109175/70R14 150 E2 THI30
1110185/65R14 EP150 INDO16
1211185/65R15 B250 JAP187
1312185/70R13 EP 150 INDO9
1413195/55R16 EP300 THI195
1514195/60R16 150EZ THI140
sheet1

and here is data in sheet2 as in range , not Table
TABLE.xlsm
ABC
1ITEMBRANDQTY
25BS 13R22.5 R187 JAP34
36BS 1400R20 R180 JAP55
43BS 1200R20 R187 JAP32
54BS 1200R24 G580 JAP12
67BS 175/65R14 B25A32 THI23
71BS 185/65R15 T001 JAP45
82BS 1200R20 G580 JAP67
98BS 175/70R13 EP150 THI67
109BS 175/70R14 ZE150 THI88
1112BS 185/70R13 EP150 INDO99
1213BS 195/55R16 EP300 THI80
1314FS 195/60R16 150EZ THI68
1410BS 185/65R14 EP150 INDO16
1511BS 185/65R15 B250 JAP187
sheet2

so I want replace items in sheet2 with item in sheet1 based on column A
the result in sheet1 should be
TABLE.xlsm
ABC
1ITEMBRANDQTY
21BS 185/65R15 T001 JAP188
32BS 1200R20 G580 JAP102
43BS 1200R20 R187 JAP133
54BS 1200R24 G580 JAP0
65BS 13R22.5 R187 JAP147
76BS 1400R20 R180 JAP97
87BS 175/65R14 B25A32 THI150
98BS 175/70R13 EP150 THI4
109BS 175/70R14 ZE150 THI30
1110BS 185/65R14 EP150 INDO16
1211BS 185/65R15 B250 JAP187
1312185/70R13 EP 150 INDO9
1413BS 195/55R16 EP300 THI195
1514FS 195/60R16 150EZ THI140
sheet1

and update in sheet1 automatically when add new or change the items when every time run the macro
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You can also put it in a standard module like this:
VBA Code:
Sub updateItems()
    With Worksheets("Sheet1").ListObjects("Table1").Range
      For i = 2 To .Rows(.Rows.Count).Row
        For j = 2 To Worksheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Row
          If .Cells(i, 1).Value = Worksheets("Sheet2").Cells(j, 1).Value Then
            .Cells(i, 2).Value = Worksheets("Sheet2").Cells(j, 2).Value
            Exit For
          End If
        Next
      Next
    End With
End Sub
And call it on button click:
VBA Code:
Private Sub Button1_Click() 'Must be your button function
  Call updateItems
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,334
Messages
6,124,319
Members
449,153
Latest member
JazzSingerNL

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