Creating and naming new worksheets

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have macro to make a new sheet from a template. In this process, the user
is asked for an account name which is then used to name the sheet. How do I
check to make sure that the same name does not already exist?
Thanks,
BradK
 
Hi Brad

You can use this function to check it

Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function


And use

If SheetExists(yourstring) = False Then.....
 
Back
Top