but when the sheets are created the always start
before sheets 1
The code below will create a new sheet always after Sheet1.
and when i delete them and recreate them it doesnt start form 2 again it will start from 13 or 14 or how ever many i created before
Yes, because Excel create the sheet with a name automatically.
The code above will name the newly created sheet to "NewSheet-01", "NewSheet-02" and so on depends on the user's input number.
When the macro above is run for the second time, it will fail if we don't delete ALL the created sheets first.
If we delete NOT ALL the created sheets first, then the macro will also fail.
If we delete ALL the created sheets first, then the macro will create a new sheet with a name (again) "NewSheet-01", "NewSheet-02" and so on depends on the user's input number.
Got an idea after reading Keebellah post .
If you want to just add a new sheet again :
So for example, after run the macro for the first time, the result is "NewSheet-01", "NewSheet-02" and "NewSheet-03".
If for example we delete just the "NewSheet-02",
the macro won't create "NewSheet-02", it just continue after the max number of the sheet name.
The next time the macro run, it will create the new sheet with the next number : "NewSheet-04", "NewSheet-05" and so on.
So now the existing created sheets name are "NewSheet-01", "NewSheet-03", "NewSheet-04", "NewSheet-05" and so on.
If for example we delete just the "NewSheet-03",
The next time the macro run, it will create the new sheet with the next number : "NewSheet-03", "NewSheet-04" and so on.
So now the existing created sheets name are "NewSheet-01", "NewSheet-02", "NewSheet-03", "NewSheet-04" and so on.
In other words, the macro won't create the sheet's name with the "lost" sheet number in between.
Bookmarks