PDA

View Full Version : Checking Tab Names



garydp
09-24-2009, 02:19 AM
Is there a way of checking the tab names when a command button is clicked. what i want to do is sheck to see if there is a tab with the same name as the sheet that it is trying to generate. if there is then a message box will let the user know that the tab name is taken.

Bob Phillips
09-24-2009, 02:25 AM
Build a Function that tells you



'-----------------------------------------------------------------
Function SheetExists(Sh As String, _
Optional wb As Workbook) As Boolean
'-----------------------------------------------------------------
Dim oWs As Worksheet
If wb Is Nothing Then Set wb = ActiveWorkbook
On Error Resume Next
SheetExists = CBool(Not wb.Worksheets(Sh) Is Nothing)
On Error GoTo 0
End Function