View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
J_Knowles[_2_] J_Knowles[_2_] is offline
external usenet poster
 
Posts: 25
Default Copy and Paste link between workbooks

Okay, this code is for the source & destination in separate workbooks.
The first try was for one workbook with 2 worksheets.

Sub FindMatchesInBooks()
Dim swb As Workbook, dwb As Workbook
Dim sd As Worksheet, dd As Worksheet
Dim cell As Range, x As Long
Dim LastRowS As Long, LastRowD As Long
Application.ScreenUpdating = False
Set swb = Workbooks("SourceData.xlsx") ' change to your workbook name
Set dwb = Workbooks("FindValuesSh1-CopyToSht2.xlsm") ' change filename
Set sd = Worksheets("source")
Set dd = Worksheets("destination")
swb.Activate
sd.Activate
LastRowS = Cells(Cells.Rows.Count, "L").End(xlUp).Row
Set rngS = Range("L2:L" & LastRowS)
dwb.Activate
dd.Activate
LastRowD = Cells(Cells.Rows.Count, "B").End(xlUp).Row
For x = 2 To LastRowD
For Each cell In rngS
If dd.Cells(x, 2).Value = cell.Value Then
dd.Cells(x, 14).Formula = cell.Offset(0, -4).Value
dd.Cells(x, 15).Formula = cell.Offset(0, -2).Value
dd.Cells(x, 16).Formula = cell.Offset(0, -1).Value
End If
Next
Next x
Application.ScreenUpdating = True
End Sub

HTH
--
Data Hog