+ Reply to Thread
Results 1 to 11 of 11

How to delete tabs before a specific tab

  1. #1
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    How to delete tabs before a specific tab

    Hello,

    Could you please help provide a vba code that can delete all the tabs before it hits the tab named "Input"? I want to keep all the tabs after this Input tabs but delete all the tabs before it.

    Thanks,

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,380

    Re: How to delete tabs before a specific tab

    That would be a very dangerous thing to do ... as far as workbook content is concerned. If anyone changed the order of the worksheets, for whatever reason, you might end up deleting the wrong sheets.

    I would recommend that you specify the sheets to keep, or delete, perhaps with a wild card.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: How to delete tabs before a specific tab

    Thank you for your input. I already thought of that, therefore I ensured the tabs follow the order. However, I'm open for suggestion using the wild card as you mentioned.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,380

    Re: How to delete tabs before a specific tab

    Depends what the tabs are called and if there is any consistency in the naming. For example, Data1, Data2, Data3, ... Input, Output1, Output2, ... Outputx.

    You could use Data* to identify the sheets to delete, or Input and Output* to identify the sheets to delete.

  5. #5
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: How to delete tabs before a specific tab

    They have different name without consistency. Can we do as I requested to delete the tabs before the Input tabs?

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to delete tabs before a specific tab

    You could try...

    Please Login or Register  to view this content.
    ...but please test on a sample workbook as you won't be able to recover the delete.
    HTH
    Regards, Jeff

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: How to delete tabs before a specific tab

    Try this code
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  8. #8
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: How to delete tabs before a specific tab

    I tried the latest code and it deleted all the sheets in the workbook.

  9. #9
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to delete tabs before a specific tab

    Quote Originally Posted by tantcu View Post
    I tried the latest code and it deleted all the sheets in the workbook.
    Ok, but what happened with the code from post #6?

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: How to delete tabs before a specific tab

    It is better to upload sample of your workbook

  11. #11
    Forum Contributor
    Join Date
    07-16-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2010
    Posts
    378

    Re: How to delete tabs before a specific tab

    Quote Originally Posted by jeffreybrown View Post
    Ok, but what happened with the code from post #6?
    I'm sorry for the confusion. It actually worked as I noticed the name in the code should be capitalized.

+ 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. VBA to copy file and delete tabs
    By shaunguyver in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2017, 07:56 PM
  2. VBA to copy file and delete tabs
    By shaunguyver in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2017, 01:24 PM
  3. Unable to delete tabs
    By gte932s in forum Excel General
    Replies: 4
    Last Post: 02-16-2016, 12:48 PM
  4. [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
  5. Replies: 1
    Last Post: 06-05-2012, 02:22 PM
  6. delete all sheet tabs apart form the first 3
    By gwithey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2008, 05:05 AM
  7. Delete Tabs
    By dogpigfish in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2005, 03:00 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