Hi,
I am trying to create a macro on a template workbook that will open a specific file in the directory and then select the specific sheet name and copy it to the template and then close. For some reason, I am only able to get it to open the specific file. All the code after won't run and I'm not getting any errors. I am probably making a rookie mistake. Can someone please correct it? Thanks in advance.
Sub importfiles()
Dim wbname As String, dt As String
Dim newwb As Workbook
Application.ScreenUpdating = False
wbnam = "\\filepath\"
dt = Format(DateSerial(Year(Date), Month(Date) - 1, 1), "mmyy")
Workbooks.Open Filename:=wbnam & "Bank 01" & dt & ".xls"
Set newwb= Workbooks("Bank 01" & dt)
newwb.Sheets("Credit Card").Copy After:=Workbooks("Template.xlsm" _
).Sheets(1)
newwb.Close False
End Sub
Bookmarks