my files
target1.xlsx
target2.xlsx
macro.xlsm
If column E of target1.xlsx matches with column A of target2.xlsx then copy and paste the column R data of target1.xlsx to target2.xlsx from column C(if column C has data then column D and if column D has then from column E and so on...)
my all files are located in same
i have written a code but it is not working so plz have a look
target1.xlsx
target2.xlsx
macro.xlsm
If column E of target1.xlsx matches with column A of target2.xlsx then copy and paste the column R data of target1.xlsx to target2.xlsx from column C(if column C has data then column D and if column D has then from column E and so on...)
my all files are located in same
i have written a code but it is not working so plz have a look
Code:
Sub Mysub()
Dim wbk1 As Workbook
Dim wbk2 As Workbook
Application.ScreenUpdating = False
Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\ap.xls")
Set wsh1 = wbk1.Worksheets(1)
Set wbk2 = Workbooks.Open(ThisWorkbook.Path & "\PL.xlsx")
Set wsh2 = wbk2.Worksheets(1)
If wsh1.Range("E1").Value = wsh2.Range("A1").Value Then
If wsh2.Range("C1").Value <> "" Then
wsh1.Range("E1").Copy wsh2.Range("C1")
End If
End If
Application.DisplayAlerts = False
wbk1.Close SaveChanges:=True
wbk2.Close SaveChanges:=True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub