+ Reply to Thread
Results 1 to 9 of 9

Macro to Delete All Sheets Except One

  1. #1
    Registered User
    Join Date
    07-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    59

    Macro to Delete All Sheets Except One

    hey guys,

    sorry for dragging out such an old post but im trying to do pretty much the same thing as this: http://www.excelforum.com/excel-prog...xcept-one.html

    the only difference is i need to copy an undefined range in the other sheets and paste them in the next available space in sheet1 (the data sheet as referred to above)

    the range in the other sheets will always start at A2 and is always the same format. i need to copy from A2 to the last row in G with data and paste it in the next row in sheet 1

    this is what i came up with but its not working. it doesnt have an error, it just doesnt do anything (except delete the other sheets)



    Please Login or Register  to view this content.
    Last edited by Paul; 07-18-2012 at 07:53 PM. Reason: Moved post to its own thread. Please read the forum rules.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to Delete All Sheets Except One

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Macro to Delete All Sheets Except One

    awesome! works a treat.

    thanks JBeaucaire!

  4. #4
    Registered User
    Join Date
    07-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Macro to Delete All Sheets Except One

    hey guys, if want to keep sheets 1 and 2, how come this doesnt work....

    Please Login or Register  to view this content.

    i also tried using 'OR' instead of and but that didnt work either
    Last edited by tbar05; 08-01-2012 at 01:37 AM.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Macro to Delete All Sheets Except One

    @tbar05
    One should not jump into someone else's thread. (Read the forum rules)
    Start your own thread and refer to this thread if really need be.



    This deletes all sheets except sheets named "Sheet1" and "Data".

    Please Login or Register  to view this content.
    Consequently, this deletes all but one sheet named "Data".

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-12-2012
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    59

    Re: Macro to Delete All Sheets Except One

    hi Jolivanes,

    i thought that since i was actually the one that started the thread it was ok....

    sorry if i was wrong.

    in either case, thanks a lot for your help. just what i was looking for

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro to Delete All Sheets Except One

    You are trying to add two values to one variable.

    Please Login or Register  to view this content.
    Don't use error statements when testing code.


    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,498

    Re: Macro to Delete All Sheets Except One

    @tbar05
    Sorry about that. You're right. I had something else going at the same time.
    My apologies

    John

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to Delete All Sheets Except One

    @tbar05, there is no rule violation for expanding your own thread as long as the expansion still relates directly to the thread title, which yours does.

    I would recommend RoyUK's approach, tweaked slightly here:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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