Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Testing to see if a sheet name exists
I have a procedure that adds a sheet and then names the sheet from a
list. Then it will add another sheet and name the next sheet from the next name in the list. My problem is that, on occassion, a name will be duplicated. I need the information associated with the both the duplicated names but you can't name 2 sheets with the same name. I don't know how to test for the existence of the name in the workbook. If I did - I could use an if statement to say that if there is a sheet with the same name then add a 1 or a space to distinguish the second sheet. I've tried on error goto line1: - but this doesn't seem to work. Can anybody help me? Thanks much in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Testing to see if a sheet name exists
Here is one I use in a menu program from a sheet name typed into a cell.
The key for you is If Sheets(ActiveCell.Value) Is Nothing Then Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) Application.DisplayAlerts = False Dim WantedSheet As String WantedSheet = Trim(ActiveCell.Value) If WantedSheet = "" Then Exit Sub On Error Resume Next If Sheets(ActiveCell.Value) Is Nothing Then GetWorkbook ' calls another macro to do that Else Sheets(ActiveCell.Value).Select ActiveSheet.Range("a4").Select End If Application.DisplayAlerts = True End Sub "anita" wrote in message m... I have a procedure that adds a sheet and then names the sheet from a list. Then it will add another sheet and name the next sheet from the next name in the list. My problem is that, on occassion, a name will be duplicated. I need the information associated with the both the duplicated names but you can't name 2 sheets with the same name. I don't know how to test for the existence of the name in the workbook. If I did - I could use an if statement to say that if there is a sheet with the same name then add a 1 or a space to distinguish the second sheet. I've tried on error goto line1: - but this doesn't seem to work. Can anybody help me? Thanks much in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
check if sheet exists | Excel Discussion (Misc queries) | |||
Checking if Sheet Exists? | Excel Discussion (Misc queries) | |||
check if the sheet/tag exists | Excel Worksheet Functions | |||
Sheet name already exists | Excel Discussion (Misc queries) | |||
check if sheet exists | Excel Programming |