Compare content

TiAc85

New Member
Joined
Oct 29, 2014
Messages
3
Hello Community,
my english isn't the best so i hope you'll understand me. I've 2 tables. Table 1 (My Master table) is full of names like Apollo, Citrus, Deng etc. In table 2 are also names and material numbers. Every month i'll get e new table 2 with maybe new material numbers.
So i like to copy automatically every "match" between table 1 and table 2 in a new table. My problem was to compare the names in table 1 und 2, because the names aren't identical. For exmaple table 1 name is Apollo and the name in table 2 is Appollo inc. or F.Apollo.
So i created a formular in table 1, which creates the name like *[name]*. After that i wrote a macro which filtered table 2 with my *[names]* and copy the names & numbers into the new table.
Now i would like to copy the real name from table 1 next to my results. But here is my problem. I count the results and copy the real name into Range c, but every real name override the one before.


Code:
Sub Match()
Dim iRow As Long
For i = 1 To ThisWorkbook.Sheets("Customer").UsedRange.Rows.Count
ThisWorkbook.Sheets("Table2").Range("$A$1:$B$118862").AutoFilter Field:=2, Criteria1:=ThisWorkbook.Sheets("Customer").Range("C" & i)
ThisWorkbook.Sheets("Table2").UsedRange.Offset(1).Copy
ThisWorkbook.Sheets("new_table").Cells(Sheets("new_table").Range("A65536").End(xlUp).Offset(1, 0).Row, 1) _
.PasteSpecial Paste:=xlPasteValues
For j = 1 To ThisWorkbook.Sheets("Tabelle2").Cells(Rows.Count, "A").End(xlUp).Row - 1
ThisWorkbook.Sheets("table1").Range("A" & i).Copy
ThisWorkbook.Sheets("new_table").Cells(j, 3).Offset(1).PasteSpecial Paste:=xlPasteValues
Next j
ThisWorkbook.Sheets("table2").ShowAllData
Next i
End Sub

I hope you understand my problem and one of you can give me an advice.
Thanks for reading my post.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Sorry,

i added the macro with some mistake and i can't edit my post. Now you can see the right one.

Code:
[COLOR=#333333]Sub Match()[/COLOR]Dim iRow As Long
For i = 1 To ThisWorkbook.Sheets("Table1").UsedRange.Rows.Count
ThisWorkbook.Sheets("Table2").Range("$A$1:$B$118862").AutoFilter Field:=2, Criteria1:=ThisWorkbook.Sheets("Customer").Range("C" & i)
ThisWorkbook.Sheets("Table2").UsedRange.Offset(1).Copy
ThisWorkbook.Sheets("new_table").Cells(Sheets("new_table").Range("A65536").End(xlUp).Offset(1, 0).Row, 1) _
.PasteSpecial Paste:=xlPasteValues
For j = 1 To ThisWorkbook.Sheets("new_table").Cells(Rows.Count, "A").End(xlUp).Row - 1
ThisWorkbook.Sheets("table1").Range("A" & i).Copy
ThisWorkbook.Sheets("new_table").Cells(j, 3).Offset(1).PasteSpecial Paste:=xlPasteValues
Next j
ThisWorkbook.Sheets("table2").ShowAllData
Next i [COLOR=#333333]End Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,223,964
Messages
6,175,658
Members
452,664
Latest member
alpserbetli

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