Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have some code that prompts users to enter the current month in an input
box, then it checks to see if a worksheet by that name already exists in the workbook. If it does exist, the subroutine ends, and if it does not exist it adds a worksheet with the name of the current month. My problem is that it is adding the new worksheet as the first worksheet and I would like it add it as the last worksheet. Can someone help me with this? Here is the code I have so far: Sub AddMonthWS() Dim myMonth As String Dim Sht As Worksheet myMonth = Application.InputBox(Prompt:="Enter the current month name:", Title:="Month", _ Type:=2) On Error Resume Next Set Sht = ActiveWorkbook.Worksheets(myMonth) On Error GoTo 0 If Sht Is Nothing Then Sheets.Add.Name = myMonth End If End Sub Thanks, Lee |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Pls Try as follows :-
Sub AddMonthWS() Dim myMonth As String Dim Sht As Worksheet myMonth = Application.InputBox(Prompt:="Enter the current month name:", Title:="Month", _ Type:=2) On Error Resume Next Set Sht = ActiveWorkbook.Worksheets(myMonth) On Error GoTo 0 If Sht Is Nothing Then Worksheets.Add after:=Worksheets(Worksheets.Count) ActiveSheet.Name = myMonth End If End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How use info in Excel shared worksheets to create new worksheets | Excel Worksheet Functions | |||
How do i assign the ActiveWorkbook.Worksheets to a worksheets object? | Excel Worksheet Functions | |||
Assigning Cells in worksheets to other data in other worksheets. | Excel Discussion (Misc queries) | |||
Sort Numerically Worksheets via VB when creating a new worksheets | Excel Programming | |||
Need code to protect worksheets - amount of worksheets varies | Excel Programming |