LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Auto Excel workbook close: save= false during an auto subroutine

I have a subroutine (macro) that automatically pulls data from various
workbooks. I would like to auto close each workbook when I am done
extracting the data.

The vba code to do this according to Excel help is:

Workbooks("BOOK1.XLS").Close SaveChanges:=False

The code works when I specify the name such as "BOOK1.XLS" . The problem is
that the file names vary depending on dates etc. So I assign a variable to
identify the names each time it is passed through the loop and incremented.
Therefore the name of each stays the same through a string variable named
"path3" as follows:

While LDR <= DOM

Workbooks.Open Filename:=path3
' extract
Selection.RemoveSubtotal
Range("A2:O2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("RwMTD.xls").Activate
Sheets("MTD Data").Select
Range("A1").Select
Selection.End(xlDown).Select
ActiveSheet.Paste
Range("A1").Select

' This would be the point at which I would want to close the (Path3) file

' LDR Value
LDR = LDR + 1
If LDR < 0 Or LDR 31 Then
MsgBox ("Please enter a valid number for the day of month i.e.(1-31)")
End
Else
If LDR 0 And LDR < 10 Then
LDR = "0" & LDR
Else
LDR = LDR
End If
End If
path2 = "\rpt." & Year & "." & month2 & "." & LDR & ".xls"
path3 = path1 & path2
' end extract

Wend
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto save and close Frank Excel Worksheet Functions 0 November 19th 09 10:50 AM
Auto Open, Refresh, Save, Close Jimmycooker Excel Discussion (Misc queries) 0 February 6th 06 01:34 PM
Auto-save worksheet on close? [email protected] Excel Discussion (Misc queries) 1 January 2nd 06 02:12 PM
Auto Close Excel Workbook MBlake[_2_] Excel Programming 2 June 2nd 05 09:44 PM
Auto Close and Save scottwilsonx[_7_] Excel Programming 3 July 7th 04 11:09 AM


All times are GMT +1. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"