copy certain data from one workbook to another workbook in excel

christinewhittle

New Member
Joined
Feb 7, 2017
Messages
11
i have two different workbooks and would like to copy & past from one to the other if certain data in one worksheet matches the other. If data in column A wb1 matches data in column A wb2 on wb1 column D will return the value of wb2 column D

workbook 1
A B C
12
misc80
15misc90
17misc100
18misc55
19misc70

<tbody>
</tbody>

work book 2
A D
1725
18
19

<tbody>
</tbody>

i haven't used excel in a while and will appreciate some guidance please... TU
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Open both workbooks. Place this macro in a regular module in wb1 and run it from there. Change the workbook name and sheet names to suit your needs.
Code:
Sub CompareLists()
    Application.ScreenUpdating = False
    Dim Rng As Range, RngList As Object
    Set RngList = CreateObject("Scripting.Dictionary")
    For Each Rng In Workbooks("wb2.xlsx").Sheets("Sheet1").Range("A2", Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp))
      If Not RngList.Exists(Rng.Value) Then
        RngList.Add Rng.Value, Nothing
      End If
    Next
    For Each Rng In Sheets("Sheet1").Range("A2", Range("A" & Rows.Count).End(xlUp))
      If RngList.Exists(Rng.Value) Then
        Range("D" & Rng.Row) = Workbooks("wb2.xlsx").Sheets("Sheet1").Range("D" & Sheets("Sheet1").Range("A:A").Find(Rng).Row)
      End If
    Next
    RngList.RemoveAll
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,978
Messages
6,128,070
Members
449,418
Latest member
arm56

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