+ Reply to Thread
Results 1 to 9 of 9

Select First And Last Worksheet in a Workbook

  1. #1
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74

    Unhappy Select First And Last Worksheet in a Workbook

    I'm trying to write a macro that will select the last sheet, and copy its contents into a new sheet (to go at the end of the workbook). The Macro will also delete the first sheet in the workbook.

    I can't seem to find code for selecting the first and last sheet in a series. I cannot use the sheet's name as the position of the sheets change every week.

    I've been trying for ages but just can't get excel to understand what I'm trying to do. If anyone can help, I'd really appreciate it.

    Chris

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

    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

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

    You can use a single line of code without declaration...
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74
    The code I have at the moment is:

    Please Login or Register  to view this content.
    I wanted to copy the last worksheet and move things around in it but it copies and pastes all of the 52 worksheets, where am i going wrong?

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I think your best option is to have a sheet prepared and saved as a template. Then simply copy the template sheet. Take a look at the Suimmary Sheet example here for example code

    http://www.excel-it.com/workbook_downloads.htm

  6. #6
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74
    Thanks for your reply Roy, I can't create a template because the information is used from the last worksheet and this is updated every week. This is why I needed to copy the last worksheet, delete the first column, move the other columns back to enter data in the new column on the right hand side. I hope that makes sense.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Some of your lines of code seem to do nothing. I've tried to edit it, but you need to test it
    Please Login or Register  to view this content.
    Last edited by royUK; 02-04-2008 at 04:59 PM.

  8. #8
    Registered User
    Join Date
    01-07-2008
    Location
    Northampton, UK
    MS-Off Ver
    version 2212, office 365 enterprise
    Posts
    74
    Thats works great, i got rid of that "clear selection", I'm not sure why it was there myself.

    Is there any way of naming the sheet as 'WEEK... followed by the number put into the input box'? (where it asks for the week number)

    Thanks for all your help,

    Chris

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Put this at the end of your code

    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