+ Reply to Thread
Results 1 to 2 of 2

Macro to recognise and delete last worksheet in book

  1. #1
    Registered User
    Join Date
    05-16-2012
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Macro to recognise and delete last worksheet in book

    Hi,

    As part of a macro I am making, I am trying to delete the first and last worksheets in the book. The first sheet is simple as it is always "Sheet1" but the last worksheet could vary depending on the size of the book.

    Sheets("Sheet1").Select
    ActiveWindow.SelectedSheets.Delete
    Sheets("Sheet34").Select
    ActiveWindow.SelectedSheets.Delete

    So in this example the last sheet is Sheet34 but next month the last worksheet could be Sheet50.

    Is there a variable I can use instead of the sheet name to recognise the last worksheet and delete it?

    Thanks

  2. #2
    Forum Expert
    Join Date
    09-27-2011
    Location
    Poland
    MS-Off Ver
    Excel 2007
    Posts
    1,312

    Re: Macro to recognise and delete last worksheet in book

    Hi try this
    Please Login or Register  to view this content.
    Regards

    tom1977

    If You are satisfied with my solution click the small star icon on the left to say thanks.

+ 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