Carlit007
New Member
- Joined
- Sep 5, 2018
- Messages
- 47
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
- 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
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