Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Create new workbook and new worksheet and close. Worksheet not saved | Excel Programming | |||
Create new workbook and new worksheet and close. Worksheet not sav | Excel Programming | |||
Create new workbook and new worksheet and close. Worksheet not sav | Excel Worksheet Functions | |||
Can I create a worksheet menu to select each other worksheet | Excel Discussion (Misc queries) | |||
Basic Question - How do I return the worksheet number of the active worksheet? | Excel Programming |