A
Ayo
I am having a little problem with the following code and I need some fresh
eyes to guide me in the right direction. What I am trying to do is open each
file in the RFDSFolder (RFDSFolder is a string representing a Folder path),
get a copy of a tab and place it in the current workbook. Then I want to
close the file and open the next file in the folder.
The problem is that I am getting a "Type mismatch" error on
"Workbooks(fl).Close SaveChanges:=False". I am having a problem using the
GetFilename method.
Any ideas?
Sub RFDS_Folder(RFDSFolder As String)
Dim fs, f, fl, fc, fn
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(RFDSFolder)
Set fc = f.Files
'For Each fl In RFDSFolder
For Each fl In fc
Workbooks.Open fl, ReadOnly:=True
Worksheets("RFDS").Copy After:=Workbooks("RFDS Tracker GA
Market_Form 4C.xls").Sheets("RFDS Tracker (2)")
Workbooks(fl).Close SaveChanges:=False
Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In Worksheets
If sh.Name = "RFDS" Then
sh.Select
ActiveWindow.SelectedSheets.Delete
End If
Next sh
Workbooks("RFDS Tracker GA Market_Form 4C.xls").Worksheets("RFDS
Tracker").Range("A4").Select
Next fl
End Sub
eyes to guide me in the right direction. What I am trying to do is open each
file in the RFDSFolder (RFDSFolder is a string representing a Folder path),
get a copy of a tab and place it in the current workbook. Then I want to
close the file and open the next file in the folder.
The problem is that I am getting a "Type mismatch" error on
"Workbooks(fl).Close SaveChanges:=False". I am having a problem using the
GetFilename method.
Any ideas?
Sub RFDS_Folder(RFDSFolder As String)
Dim fs, f, fl, fc, fn
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(RFDSFolder)
Set fc = f.Files
'For Each fl In RFDSFolder
For Each fl In fc
Workbooks.Open fl, ReadOnly:=True
Worksheets("RFDS").Copy After:=Workbooks("RFDS Tracker GA
Market_Form 4C.xls").Sheets("RFDS Tracker (2)")
Workbooks(fl).Close SaveChanges:=False
Dim sh As Worksheet
Application.DisplayAlerts = False
For Each sh In Worksheets
If sh.Name = "RFDS" Then
sh.Select
ActiveWindow.SelectedSheets.Delete
End If
Next sh
Workbooks("RFDS Tracker GA Market_Form 4C.xls").Worksheets("RFDS
Tracker").Range("A4").Select
Next fl
End Sub