+ Reply to Thread
Results 1 to 3 of 3

Macro keeps looking for sheet1, won't use sheet2, sheet3 . . .

  1. #1
    Registered User
    Join Date
    07-26-2011
    Location
    U.S.
    MS-Off Ver
    Excel 2010
    Posts
    5

    Macro keeps looking for sheet1, won't use sheet2, sheet3 . . .

    I have a macro that I use many times in a row. One of the actions it performs is creating a new sheet, which is then deleted before I run the macro again. Of course this first sheet is named "sheet1". However when I delete it (it has to be deleted) and run the macro again it creates a new sheet named "sheet2", and then ceases to function. I tried renaming the sheet as part of the macro, but that didn't work. My question: is there anyway to stop excel from naming the next new sheet created a sequential number. Or might there be another solution to my problem?

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

    Re: Macro keeps looking for sheet1, won't use sheet2, sheet3 . . .

    When you create the new sheet, why not rename the sheet at the same time.

    Example:

    Please Login or Register  to view this content.
    HTH
    Regards, Jeff

  3. #3
    Valued Forum Contributor gjlindn's Avatar
    Join Date
    08-01-2011
    Location
    Dodgeville, WI
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    369

    Re: Macro keeps looking for sheet1, won't use sheet2, sheet3 . . .

    Hi salvator. In your code are you referencing the worksheet name for deletion or the object name for deletion. Ex. Sheet1.Delete is the object and Sheets("Sheet1").Delete is the sheet name. I don't believe there is a way to not sequentially number new sheets. There are ways to change both the Name and the CodeName programmatically. If this doesn't help, post your code and I'll take a stab at it. Thanks!

    -Greg

+ 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