View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
FinChase FinChase is offline
external usenet poster
 
Posts: 21
Default Add worksheets at end

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