replace data from sheet

1MooreMike

New Member
Joined
Jun 5, 2018
Messages
4
Hi Everyone -

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>
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?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Cross posted https://www.excelforum.com/excel-pr...3295-replace-data-from-sheet.html#post4911861

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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