[![enter image description here][1]][1]I have two files. One get's updated and emailed daily. The other is the "Master" file[![enter image description here][2]][2] that I want to add the button/macro to. That is when running the Macro in the Master file I want to look through Column B on the daily updated file. If the Part Number is present in both that Column B (Sheet "Status") on the daily file and the Master file (Column H) the paste Columns C-N into the Master File (Sheet "XCHART") starting at Column AK
Sub CopyRange()
Dim a As Worksheet
Dim b As Worksheet
Dim rng As Range
'open the workbooks
Workbooks.Open "D:\OfficeDev\Excel\201510\Master.xlsx"
Set a = Workbooks("Master.xlsx").Worksheets("Sheet1")
Workbooks.Open "D:\OfficeDev\Excel\201510\MasterBak.xlsx"
Set b = Workbooks("MasterBak.xlsx").Worksheets("Sheet1")
'loop the cells in column B
For r = 2 To a.UsedRange.Rows.Count
If Trim(a.Cells(r, 2)) <> "" Then
With b.Range("B:B")
Set rng = .Find(What:=a.Cells(r, 2), _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
'write code to copy the cells
Debug.Print a.Cells(r, 2)
End If
End With
End If
Next
End Sub