Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() How do I check if a worksheet exists or not before accessing it. -- skvabbili ------------------------------------------------------------------------ skvabbili's Profile: http://www.excelforum.com/member.php...o&userid=34135 View this thread: http://www.excelforum.com/showthread...hreadid=539068 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This function will let you know if a sheet exists...
Public 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 Use it like... if sheetexists("Sheet1") then sheets("Sheet1").Select -- HTH... Jim Thomlinson "skvabbili" wrote: How do I check if a worksheet exists or not before accessing it. -- skvabbili ------------------------------------------------------------------------ skvabbili's Profile: http://www.excelforum.com/member.php...o&userid=34135 View this thread: http://www.excelforum.com/showthread...hreadid=539068 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If SheetExists(sheetname) Then
' '----------------------------------------------------------------- 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 -- HTH Bob Phillips (remove xxx from email address if mailing direct) "skvabbili" wrote in message ... How do I check if a worksheet exists or not before accessing it. -- skvabbili ------------------------------------------------------------------------ skvabbili's Profile: http://www.excelforum.com/member.php...o&userid=34135 View this thread: http://www.excelforum.com/showthread...hreadid=539068 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Worksheet exists | Excel Programming | |||
Check if a worksheet exists | Excel Programming | |||
How to check if a worksheet exists in worksheet collection | Excel Programming | |||
Worksheet Exists... | Excel Programming | |||
How can I tell if a worksheet exists? | Excel Programming |