For example if I want to copy data ("B1:B8") from workbook1 sheet 1 and paste it into ("D1:D8") of another workbook sheet 1 but this has to done by referring or comparing the cells (A1:A8) of book 1 and cells (C1:C8) has only same values then paste else skip or do nothing.
Example: Book1 Sheet1 I had lined up;
COL A COL B app yes conf pass gif no pic fail bit yes map yes conf yes bit no
Now in Workbook 2 Sheet 1 I was given in COL C as,
COL C app conf gif pic gif pic bit gif
So in COL D I have to paste values only for those COL A and COL C equal ones if those were not equal skip or paste nothing in COL D
I have written code something like this but unfortunately its pasting everything!!
Sub Copy_range()
Dim x As Workbook
Dim y As Workbook
Dim rng As Range
Dim c As Range
Dim i As Long
Set x = ActiveWorkbook
Set y = Workbooks.Open(x.Sheets(1).Range("G1"))
Set rng = x.Sheets(1).Range("A1:A8")
Set c = y.Sheets(1).Range("C1:C8")
For i = 1 To i + 1
If x.Sheets(1).Range("A1:A8").End(xlUp).Row = y.Sheets(1).Range("C1:C8").End(xlUp).Row Then
x.Sheets(1).Range("B1:B8").Copy
y.Sheets(1).Range("D1:D8").PasteSpecial
y.Close
End If
Next
End Sub