R
rglasunow
I am currently running a macro from another workbook and asking it to
add a new workbook. It adds the new workbook fine and copies all the
data into the new workbook. After it has done this an error pops up
and highlights
Set WB = Workbooks.Open(FName)
What am I doing wrong that is causing this to happen?
Sub Summary()
Application.ScreenUpdating = False
Dim FName As String
Dim WB As Workbook
Dim Dest As Range
Const FOLDERNAME = "C:\Excel Test"
ChDrive FOLDERNAME
ChDir FOLDERNAME
Workbooks.Add
Set Dest = Range("A2")
FName = Dir("*.xls")
Do Until FName = "stop.xls"
Set WB = Workbooks.Open(FName)
WB.Worksheets(1).Rows(2).Copy Destination:=Dest
WB.Close savechanges:=False
Set Dest = Dest(2, 1)
FName = Dir()
Loop
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\Excel Test\Summary - " &
Format(Date, "mm-dd-yyyy") & ".xls"
ActiveWorkbook.Close
End Sub
Any advise is greatly appreachiated!!
add a new workbook. It adds the new workbook fine and copies all the
data into the new workbook. After it has done this an error pops up
and highlights
Set WB = Workbooks.Open(FName)
What am I doing wrong that is causing this to happen?
Sub Summary()
Application.ScreenUpdating = False
Dim FName As String
Dim WB As Workbook
Dim Dest As Range
Const FOLDERNAME = "C:\Excel Test"
ChDrive FOLDERNAME
ChDir FOLDERNAME
Workbooks.Add
Set Dest = Range("A2")
FName = Dir("*.xls")
Do Until FName = "stop.xls"
Set WB = Workbooks.Open(FName)
WB.Worksheets(1).Rows(2).Copy Destination:=Dest
WB.Close savechanges:=False
Set Dest = Dest(2, 1)
FName = Dir()
Loop
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="C:\Excel Test\Summary - " &
Format(Date, "mm-dd-yyyy") & ".xls"
ActiveWorkbook.Close
End Sub
Any advise is greatly appreachiated!!