Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Insert Sheet

What is the code to insert a sheet and name it when it is
insert. This is what I have, but it won't work if there
already is a sheet4.

Sheets.Add
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "Worksheet"

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Insert Sheet


Worksheets.Add.Name = "Bob"

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

wrote in message
...
What is the code to insert a sheet and name it when it is
insert. This is what I have, but it won't work if there
already is a sheet4.

Sheets.Add
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "Worksheet"

Thank you



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Insert Sheet

Try this

Sub test()
On Error Resume Next
Sheets.Add.Name = "Worksheet"
If Err.Number 0 Then
MsgBox "Change the name of : " & ActiveSheet.Name & " manually"
Err.Clear
End If
On Error GoTo 0
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message ...
What is the code to insert a sheet and name it when it is
insert. This is what I have, but it won't work if there
already is a sheet4.

Sheets.Add
Sheets("Sheet4").Select
Sheets("Sheet4").Name = "Worksheet"

Thank you



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
insert sheet tab is not functioning and can't add new sheet LoLo Excel Worksheet Functions 5 April 2nd 23 07:06 PM
Insert Sheet Karthik Excel Worksheet Functions 2 March 13th 09 06:34 AM
Can not insert sheet??? S Davis Excel Worksheet Functions 2 March 15th 07 06:41 PM
insert query into excell sheet to update excell sheet and pivot table vbsolo Excel Discussion (Misc queries) 0 August 24th 05 12:41 PM
Inserting a row in sheet A should Insert a row in sheet B, removing a row in Sheet A should remove the corresponding row in sheet B Hannes Heckner Excel Programming 1 March 5th 04 09:10 AM


All times are GMT +1. The time now is 02:57 AM.

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

About Us

"It's about Microsoft Excel"