Importing new data only to mastersheet

Carlit007

New Member
Joined
Sep 5, 2018
Messages
35
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
  2. MacOS
Hi I have tried the code below and it almost works flawlessly for my needs to explain a little what I have going on.
I have a sheet called "PropertyLocation" consisting of serialized equipment and their current locations.

every so often I receive new equipment and I would like to add to "PropertyLocation" worksheet
these new equipment would be on my "Import" worksheet which consist of a mix of old and new equipment.

what I want to do is when I run the VBA code for only new equipment to be added to my "Property Location" sheet
the new items should only be imported if the serial number which is located in column "A" does not already exist

I am currently using the following VBA Code from the following tread Update a Master Sheet with Changed or New Data From Another Sheet

VBA Code:
Sub ImportNewDataOnly()

Dim LRow As Long, i As Long
Dim varData As Variant
Dim c As Range

With Sheets("Import")
    LRow = .Cells(Rows.Count, 1).End(xlUp).Row
    varData = .Range("A2:U" & LRow)
End With
    
With Sheets("PropertyLocation")
    For i = LBound(varData) To UBound(varData)
        Set c = .Range("A:A").Find(varData(i, 1), LookIn:=xlValues, LookAt:=xlWhole)
        If c Is Nothing Then
            .Cells(Rows.Count, 1).End(xlUp)(2).Resize(1, UBound(varData, 2)) _
                = Application.Index(varData, i)
        Else
            .Cells(c.Row, 1).Resize(1, UBound(varData, 2)) _
                = Application.Index(varData, i)
        End If
    Next
End With
End Sub
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

EXCEL MAX

Board Regular
Joined
Nov 11, 2020
Messages
243
Office Version
  1. 2007
Platform
  1. Windows
Hi Carlit007,
What is the problem? This code works.
 

Watch MrExcel Video

Forum statistics

Threads
1,118,775
Messages
5,574,159
Members
412,574
Latest member
shadowfighter666
Top