+ Reply to Thread
Results 1 to 2 of 2

VBA to copy file and delete tabs

  1. #1
    Registered User
    Join Date
    02-09-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    92

    VBA to copy file and delete tabs

    I have an Excel spreadsheet (called 'Finance Tool.xlsm') with about 10 tabs (Sheet 1, Sheet 2, Sheet 3, etc), and I would like to include a procedure that does the following:

    1) Copies the whole workbook ('Finance Tool.xlsm') to a new workbook.
    2) Deletes all of the tabs apart from Sheet 1, Sheet 2, and Sheet 3.
    4) Saves the workbook to a folder (/Temp) and gives it a name based on today's date.
    5) Closes the file and returns me to the original workbook.

    I have tried code from a few different sources but can't seem to get the procedure as a whole to work. I especially have problems with the deletion of tabs.

    Any guidance would be much appreciated!

    Many thanks in advance

    Shaun

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: VBA to copy file and delete tabs

    Hello shaunguyver,

    This will copy the sheets named "Sheet 1", "Sheet 2", "Sheet 3" to a new workbook along with any VBA Worksheet event code. If the worksheet names don't match then you will get an error message. The workbook is saved as an xlsb format in the TEMP directory named yyyy-mm-dd. This will allow the workbook to be either an xlsx or xlsm without changing the extension.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macros to Group Tabs, Delete Row, and Ungroup Tabs Required???
    By seash in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-16-2015, 09:15 AM
  2. Copy Tabs from different excel file by using code name of the tabs
    By varun.kalra1988 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-15-2014, 02:03 PM
  3. Macro to copy workbook every 3 months, give new name, and delete all tabs except 1
    By scottatbuckman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-07-2014, 09:57 AM
  4. [SOLVED] looper to copy tabs of a data file into template and save as
    By amartin575 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 02-26-2014, 10:47 AM
  5. VBA move multiple and selected sheets/tabs to new file and copy file as value
    By NeilM in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2013, 06:19 AM
  6. Replies: 2
    Last Post: 05-06-2013, 06:41 PM
  7. Delete excel file after copy
    By Jeff in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-15-2005, 10:05 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