Results 1 to 3 of 3

Thread: SOLVED adding worksheets

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2003
    Location
    Los Angeles, CA
    Posts
    49

    SOLVED adding worksheets

    I recorded the following macro:
    Code:
    Sheets("Sheet2").Select
    Sheets.Add
    Sheets("Sheet2").Select
    Sheets("Sheet2").Name = "name"
    The problem is that I'm going to be adding multiple sheets. Which brings me to my question: How can I change the name of the sheet that I just added?

    Thanks,
    Alex
    Last edited by LodBot; Jul 14th, 2003 at 10:40 AM.

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Excel keeps track of the active worksheets in a workbook within a worksheets collection. One property of this collection is count which you can use to help you here:
    VB Code:
    1. Worksheets.Add After:=Worksheets(Worksheets.Count)
    2. Worksheets(Worksheets.Count).Name = "MyNewSheetName"
    Here I'm saying "add a new worksheet after the last existing one in this workbook, then go to this new last sheet I just created & change it's name..."

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2003
    Location
    Los Angeles, CA
    Posts
    49
    works

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width