Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
what function do i use to determine if a worksheet name already exists;
or should i use error trapping to catch an attempt at creating a redundant worksheet name? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can error trap or use a function
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 This in you macro If SheetExists("Master") = True Then.... Or Sub sheettest() Dim N As Long On Error Resume Next With ThisWorkbook.Worksheets N = Len(.Item("Report").Name) If N = 0 Then 'your code End If End With End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "mark kubicki" wrote in message ... what function do i use to determine if a worksheet name already exists; or should i use error trapping to catch an attempt at creating a redundant worksheet name? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
proposedname = "Sheet1"
for each sh in worksheets if lcase(sh.name) = lcase(proposedname) then msgbox "Name is a duplicate" exit for end if Next End Sub or you can error trap. -- Regards, Tom Ogilvy "mark kubicki" wrote in message ... what function do i use to determine if a worksheet name already exists; or should i use error trapping to catch an attempt at creating a redundant worksheet name? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find value in more than 100 worksheets at once | Excel Worksheet Functions | |||
Find sum across all worksheets | Excel Worksheet Functions | |||
How can you find how many worksheets in a workbook? | Excel Discussion (Misc queries) | |||
Using a collection class to implement mutliple find/replace strings in cells | Excel Programming | |||
How to find the type of Sheet in Excel.Workbook.sheets collection | Excel Programming |