Macro to Close a specific workbook.

D

Dmad11

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
 
D

Don Guillett

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top