Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 6
Default Help changing the sheet name

Hello everyone,

When you create a new sheet in Excell 2007, it calls it Sheet1 and obviously this increments for each new sheet, the next one being Sheet2, Sheet3 etc.

My question is that is there anyway to change the default name it calls new sheets? The reason is, I have a Macro that creates a sheet, and then renames it. The problem is, I can only run this Macro once.

Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Sheet2").Select
Sheets("Sheet2").Name = "Pete"

If I run this Macro again, then the new sheet is called "Sheet3" and not "Sheet2", so my Macro throws an error.

If I could change it so that every new sheet was called, for example "new", then my Macro could always reference "new" and rename it to "pete", no matter how many times its run.

Now your probably going to ask why I would want to run this more than once, as I cannot have two sheets called "Pete" anyway. Well, the Macro firstly deletes the sheet called Pete, before doing a bunch of other stuff and lastly creating the sheet again. So there never is a situation where there would be more than one sheet called "Pete".

Is anyone able to help with this? An alternative solution would be rather than delete the "Pete" sheet it just clears all the contents held in it - but the problem is if I do this, the sheet becomes empty as expected but at the point where data is pasted in, the Macro throws a run time error and crashes my entire work book. I think this is a bug in Excel itself as the macro runs fine if the sheet is brand new.

Any help is greatly appreciated.

Many thanks.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the name of a sheet Cole C. Excel Discussion (Misc queries) 1 April 21st 09 08:03 PM
Referencing a sheet name thats ever changing [email protected][_2_] Excel Programming 0 March 13th 07 03:49 PM
Protect from changing sheet name Sloth Excel Discussion (Misc queries) 6 January 23rd 06 08:27 PM
Changing Sheet Names Gavin Ling Excel Programming 5 January 6th 06 05:58 PM
Changing Sheet Name Andym Excel Programming 1 February 1st 05 04:02 PM


All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"