I have a range of unique project IDs in 2 workbooks. One of the workbooks doesn't contain the details of the projects, while the other workbook contains all of the project details.
I want to pull out the information from one workbook according to the unique project ID found in the other workbook. I have tried coding this, but it only works for extracting the data from the external workbook for the one with the project ID. I need it to work to extract the data for a range of project IDs given in a column.
This is the code I currently have:
Sub AAA()
If Workbooks("Source.xlsm").Sheets("Sheet2").Range("A2").Value = Workbooks("Target.xlsm").Sheets("Sheet1").Range("A2").Value Then
Workbooks("Source.xlsm").Sheets("Sheet2").Range("B2").Value = Workbooks("Target.xlsm").Sheets("Sheet1").Range("C2").Value
End If
End Sub
This code only works for a particular cell, but I would need to extract a range of data from a range of project IDs located in the external workbook. What can I do to get this to work?
VLOOKUPfunction works. Have you considered using this non-VBA approach? If so, can you tell us why it didn't work?