Add a new sheet with name in A1 : Worksheet Add « Excel « VBA / Excel / Access / Word






Add a new sheet with name in A1

 
Sub AddSheetWithNameCheckIfExists()
    Dim ws As Worksheet
    Dim newSheetName As String
    newSheetName = Sheets(1).Range("A1")
        For Each ws In Worksheets
            If ws.Name = newSheetName Or newSheetName = "" Or IsNumeric(newSheetName) Then
                MsgBox "Sheet already exists or name is invalid", vbInformation
                Exit Sub
            End If
        Next
        Sheets.Add Type:="Worksheet"
        With ActiveSheet
            .Move After:=Worksheets(Worksheets.Count)
            .Name = newSheetName
        End With
End Sub

 








Related examples in the same category

1.Create a new sheet with month name and year as its name
2.Add a new Sheet
3.Creating a new worksheet for your workbook, and then it fills in several cells in that new worksheet.
4.Inserts new monthly sheet
5.Add a worksheet and append value
6.Add a worksheet and save it
7.Append a worksheet to the end of the worksheet list