Results 1 to 5 of 5

Macro to close open files without saving it

Threaded View

Roma1r Macro to close open files... 01-08-2019, 09:11 AM
BellyGas Re: Macro to close open files... 01-08-2019, 09:18 AM
mohan.r1980 Re: Macro to close open files... 01-08-2019, 10:53 AM
mohan.r1980 Re: Macro to close open files... 01-08-2019, 10:24 AM
mohan.r1980 Re: Macro to close open files... 01-09-2019, 02:56 AM
  1. #1
    Registered User
    Join Date
    01-02-2014
    Location
    Cape Town
    MS-Off Ver
    Excel 2007
    Posts
    88

    Macro to close open files without saving it

    Require assistance with setting up a macro.

    The macro the way it’s currently setup reads a filename in a cell reference (data extraction worksheet, cell reference b7) and opens that file, copies data back to the main workbook and then opens the next file (data extraction worksheet, cell reference b8). Before the file copy, it unhides a worksheet (where it’s copying from).

    I need assistance with closing the files opened (in cell reference b7 and b8) within the macro, and no need to save.
    Sub Open_ExistingWorkbook()
    
        filetoopen = ThisWorkbook.Worksheets("data extraction").Range("b7")
        Workbooks.Open Filename:=filetoopen
        Sheets("Payspace").Visible = True
        Sheets("Payspace").Select
        Range("A4").Select
        Range("A4:D117").Select
        Selection.Copy
        Windows("T&O PaySpace upload template_ 2019 - test.xlsm").Activate
        Sheets("Location A").Select
        Range("A7").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveWindow.SmallScroll Down:=-21
        Sheets("Data extraction").Select
        Range("A16").Select
             
        filetoopen = ThisWorkbook.Worksheets("data extraction").Range("b8")
        Workbooks.Open Filename:=filetoopen
        Sheets("Payspace").Visible = True
        Sheets("Payspace").Select
        Range("A4").Select
        Range("A4:D117").Select
        Selection.Copy
        Windows("T&O PaySpace upload template_ 2019 - test.xlsm").Activate
        Sheets("Location B").Select
        Range("A7").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveWindow.SmallScroll Down:=-21
        Sheets("Data extraction").Select
        Range("A16").Select
           
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Open and close files using excel macro
    By laxmanann in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-16-2014, 12:06 PM
  2. [SOLVED] macro to open all files in a folder, save them, then close them
    By hopefulhart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-27-2013, 06:40 PM
  3. [SOLVED] Macro to open and close all files in a folder and sub folders
    By BillDoor in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-31-2012, 06:51 AM
  4. Macro to open, copy/paste, and close files with variable name
    By mjr33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2011, 10:20 PM
  5. Macro to Open, Save and Close Excel Files
    By az! in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2011, 04:19 AM
  6. Macro to Open, Print and Close multiple PDF Files
    By Herve_Rob in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-09-2009, 05:08 AM
  7. Macro to open all files, make changes, save and close
    By certain_death in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-20-2009, 03:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1