Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Create new worksheet and use a number as its name..

I have a workbook that uses the following macro to create new
worksheets. What i would like to be able do is to create the sheet,
and have it automatically named [ in this case the name would a
number [2 or 3 or 4 or 5 etc etc]. The last sheet in the workbook
[ the rightmost tab] would be sheet '1' at the start. The newly
created sheet would be to the right if this, and I would want it to be
sheet '2'. Then the next sheet, created to the right of sheet '2',
would be named '3', and so on. How do I modify or change this VBA to
accomplish this?

Thanks,

Tonso

Dim sName As String
Dim wks As Worksheet
Answer = MsgBox("Do you want create a new MOST Sub-Operation?",
vbYesNo)
If Answer < vbYes Then Exit Sub
Worksheets("T").Copy After:=Sheets(Worksheets.Count)
Set wks = ActiveSheet
Do While sName < wks.Name
sName = Application.InputBox _
(Prompt:="Enter new worksheet name")
On Error Resume Next
wks.Name = sName
On Error GoTo 0
Loop
Set wks = Nothing
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Create new worksheet and use a number as its name..

On Oct 8, 10:11*am, Billy wrote:
I have a workbook that uses the following macro to create new
worksheets. What i would like to *be able do is to create the sheet,
and have it automatically named [ in this case the name would *a
number [2 or 3 or 4 or 5 etc etc]. The last sheet in the workbook
[ the rightmost tab] would be sheet '1' at the start. The newly
created sheet would be to the right if this, and I would want it to be
sheet '2'. Then the next sheet, created to the right of sheet '2',
would be named '3', and so on. How do I modify or change this VBA to
accomplish this?

Thanks,

Tonso

Dim sName As String
* * Dim wks As Worksheet
* * Answer = MsgBox("Do you want create a new MOST Sub-Operation?",
vbYesNo)
* * If Answer < vbYes Then Exit Sub
* * Worksheets("T").Copy After:=Sheets(Worksheets.Count)
* * Set wks = ActiveSheet
* * Do While sName < wks.Name
* * * * sName = Application.InputBox _
* * * * * (Prompt:="Enter new worksheet name")
* * * * On Error Resume Next
* * * * wks.Name = sName
* * * * On Error GoTo 0
* * Loop
* * Set wks = Nothing


Sub copysheetandnamenextindex()
Sheets("Sheet5").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = "Sh" & Sheets(Sheets.Count).Index
End Sub
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
Create new workbook and new worksheet and close. Worksheet not saved Patrick Molloy Excel Programming 0 July 25th 09 07:00 PM
Create new workbook and new worksheet and close. Worksheet not sav Patrick Djo Excel Programming 0 July 21st 09 02:19 PM
Create new workbook and new worksheet and close. Worksheet not sav Patrick Djo Excel Worksheet Functions 0 July 20th 09 07:10 PM
Can I create a worksheet menu to select each other worksheet pippagrace Excel Discussion (Misc queries) 4 June 23rd 06 01:28 PM
Basic Question - How do I return the worksheet number of the active worksheet? Regnab Excel Programming 2 May 17th 06 03:02 AM


All times are GMT +1. The time now is 02:02 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"