View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Macro to Close a specific workbook.

Why are you recreating FN as you go along? Just use the FIRST FN. Try this

Dim FN As String
FN = Range("'Macro Control'!B7")
Dim FNX As String
FNX = Range("'Macro Control'!B7")

Application.DisplayAlerts = False
Workbooks.Open Filename:=FN
Range("D1:W28").Copy
Windows("Daily MTM Signoff Template.xls").Activate
Sheets("Current Day CFlash Report").Select
Range("D4").PasteSpecial Paste:=xlPasteValues
Aplication.DisplayAlerts = TRUE

Windows(FN).Activate
ActiveWorkbook.Close savechanges:=False

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Dmad11" wrote in message
...
Hello,

So what my macro does is look up on a "Macro Control" sheet of my
workbook to get different variables based on the day to open and grab
specific information. It is working fine up until the point that I
try to close it. It stops at the "Windows (FN) .Activate". Can
someone please tell me what I am doing wrong here or how I can somehow
bypass this?

Thanks so much!

Dan



Here is the part of the macro:


Dim FN As String
FN = Range("'Macro Control'!B7")
Dim FNX As String
FNX = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

Workbooks.Open Filename:=FN
Range("D1:W28").Select
Selection.Copy
Windows("Daily MTM Signoff Template.xls").Activate
Sheets("Current Day CFlash Report").Select
Range("D4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


FN = Range("'Macro Control'!B7")
FNX = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

FN = Range("'Macro Control'!B7")
Application.DisplayAlerts = False

Windows(FN).Activate
ActiveWorkbook.Close savechanges:=False