Copy row of data to another worksheet only when the data does not exist in that worksheet

Podder1965

New Member
Joined
Feb 10, 2021
Messages
14
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I am trying to copy rows of new data from one worksheet to a Master worksheet only when the new data does not exist in the Master worksheet.
Currently, I have the following setup in the Master worksheet:
Country Colour Type
England Red 2
Scotland Blue 2
Scotland Blue 3
Scotland Red 7
England Blue 4

I then get new data with the same format as above, in another worksheet
Country Colour Type
France Brown 3
Scotland Blue 2
Germany White 4

What I want to achieve (if possible) is to determine if the rows of new data exist in the Master worksheet and if so ignore them but if they don't then copy them to the existing data.
So the above Master worksheet would look like this:
Country Colour Type
England Red 2
Scotland Blue 2
Scotland Blue 3
Scotland Red 7
England Blue 4
France Brown 3
Germany White 4

Thanks in advance
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi. Try this code, please.
As you run the code the sheet to copy data from should be the active one.
VBA Code:
Sub ReplicateData()
 Dim cct As Range
  For Each cct In Range("A2:A" & Cells(Rows.Count, 1).End(3).Row)
   If Application.CountIf(Sheets("Master").[A:A], cct.Value) = 0 Then cct.Copy Sheets("Master").Cells(Rows.Count, 1).End(3)(2)
  Next cct
End Sub
 
Upvote 0
Solution
Hi. Try this code, please.
As you run the code the sheet to copy data from should be the active one.
VBA Code:
Sub ReplicateData()
 Dim cct As Range
  For Each cct In Range("A2:A" & Cells(Rows.Count, 1).End(3).Row)
   If Application.CountIf(Sheets("Master").[A:A], cct.Value) = 0 Then cct.Copy Sheets("Master").Cells(Rows.Count, 1).End(3)(2)
  Next cct
End Sub
Osvaldo,
Works perfectly,
Cheers
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,273
Members
448,559
Latest member
MrPJ_Harper

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