1MooreMike
New Member
- Joined
- Jun 5, 2018
- Messages
- 4
Hi Everyone -
I use this often to replace data on my sheet:
Column A is common between all sheets. The above replaces data, so if I have a line (Unit #) in Column A in Book2 that isn't in Book1, it makes everything blank on that line - I want to keep existing data and only replace data points that exist in Book2.
Basically, I want to develop a macro that when I run with book2 open, it updates the units (Column A) in Book1 based on data from Book2, but leaves the other 'units' (Column A) alone.
Any suggestions?
I use this often to replace data on my sheet:
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Private Sub Update_EstDelv1()
Dim lr As Long, I As Long
Dim x As Variant
lr = Range("A1").End(xlDown).Row
For I = 1 To lr
x = Application.VLookup(Cells(I, "A"), Workbooks("Reference.xlsx").Sheets("Sheet1").Columns("A:BX"), 23, False)
If Not (IsError(x)) Then
Cells(I, "W").Value = x
End If
Next I
End Sub
</code>
Basically, I want to develop a macro that when I run with book2 open, it updates the units (Column A) in Book1 based on data from Book2, but leaves the other 'units' (Column A) alone.
Any suggestions?