I am in need of some help and ideas.
I have a folder, let's say this one C:\Users\ Me \Desktop\Test Dir\Files\
In this folder I have several workbooks and my Master Workbook named Test.xlsm
In my master Workbook I have several sheets with different names AB11, AB12, BC13 etc
I want to build a code that will copy and move the sheet AB1 to a excel file in the folder whose name ends with AB1 (or maybe contains this word).
And then the loop will continue. If the next Excel file ends with AB2, then copy and move the sheet AB2 from my Master Workbook.
Any ideas? What I have so far is:
However, my file cannot be found , the one that ends with the name "AB11"
Dim myPath As String
Dim myFileAB11 As Workbook
Dim wb As Workbook
myPath = "C:\Users\Me\Desktop\Test\Split "
filenamefilters = Array("AB11.xlsx", "AB12.xlsx", "BC13.xlsx", "BC14.xlsx")
myFileAB11 = Dir(myPath & "*AB115*.xls", vbNormal)
myFileAB12 = Dir(myPath & "*AB12*.xls", vbNormal)
myFileBC13 = Dir(myPath & "*BC13*.xls", vbNormal)
myFileBC14 = Dir(myPath & "*BC14*.xls", vbNormal)
Workbooks.Open (Dir(myPath & "*GB55.xlsx", vbNormal))
Workbooks(myFileAB11).Activate
Sheets.Add
ActiveSheet.Name = "AB11"
Workbooks.Open Filename:="C:\Users\Me\Desktop\Test\Test.xlsm"
Sheets(AB11).Copy Before = Workbooks(myFileAB11).Sheets(Sheets.Count)
ActiveSheet.Name = "AB11"
End Sub