Keith.Jackson
Board Regular
- Joined
- Mar 31, 2005
- Messages
- 115
what would be a macro to create a new worksheet with the name of a name I have typed in a cell?
ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = Worksheets("Sheet1").Range("A1").Value
Sub create_sheet()
Dim ShName As String
Dim ShExists As Boolean
ShName = Sheets("Sheet1").Range("A1").Text
On Error Resume Next
ShExists = Len(Worksheets(ShName).Name) > 0
On Error GoTo 0
If ShExists Then
MsgBox "Worksheet already exists", 48, "Title"
Else
ActiveWorkbook.Worksheets.Add After:=Worksheets(Worksheets.Count)
ActiveSheet.Name = ShName
End If
End Sub