Does this perform the desired operation:
Sub Sample()
Dim wbA As Workbook, wbB As Workbook, wbM As Workbook
Dim sFilePath As String, rCell As Range, sWB As String
Set wbM = ThisWorkbook 'The Master Workbook
sFilePath = "C:\Users\Admin\Desktop\Oracle\USD\FYD.xlsb" 'hard coded version (left unchanged from your code sample)
Set wbA = Workbooks.Open(Filename:=sFilePath & "\" & A.xlsb) 'Amend as necessary
Set wbB = Workbooks.Open(Filename:=sFilePath & "\" & B.xlsb) 'Amend as necessary
For Each rCell In wbM.Worksheets("Master").Range("A2:A200")
If InStr(rCell, "-451414-") > 0 Then
sWB = rCell.Offset(7, 0)
With Excel.Workbooks(sWB)
.Worksheets("REK").Range("E65000").End(xlUp).Offset(1).Resize(, 12) = _
Application.Index(Split(Join(Array(Replace$(Replace$(rCell, "-0-", "-000000-"), "-", "|"), "00000000", "000", "MAY-15", "USD", "AMOUNT", rCell.Offset(, 3), "NO"), "|"), "|"), Array(1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12))
End With
End If
Next
End Sub
Bookmarks