Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default On Error Goto ignored

I wanted to determine whether a sheet existed in the active workbook. So I
used:

On Error Goto NoPerfSheet
Sheets("Performance").Select
On Error Goto 0

However, Excel always stopped at the Sheets command, with a Subscript out of
range error.

I knew there would never be more than two sheets in the workbook, so I got
it working by using:

IF Sheets.Count = 1 Goto NoPerfSheet

However, I'm why the On Error statement was ignored.

What conditions causes VBE to ignore On Error?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default On Error Goto ignored

Fred,

something like this

Function SheetExists(strName As String) As Boolean
Dim shName As Worksheet
On Error Resume Next
Set shName = Sheets(strName)
On Error GoTo 0
SheetExists = Not shName Is Nothing
End Function

Robin Hammond
www.enhanceddatasystems.com

"Fred Smith" wrote in message
...
I wanted to determine whether a sheet existed in the active workbook. So I
used:

On Error Goto NoPerfSheet
Sheets("Performance").Select
On Error Goto 0

However, Excel always stopped at the Sheets command, with a Subscript out
of range error.

I knew there would never be more than two sheets in the workbook, so I got
it working by using:

IF Sheets.Count = 1 Goto NoPerfSheet

However, I'm why the On Error statement was ignored.

What conditions causes VBE to ignore On Error?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default On Error Goto ignored

That's a workaround I hadn't thought of, and I could see using it sometime.
Buy why was my On Error Goto ignored?

--
Regards,
Fred
Please reply to newsgroup, not e-mail


"Robin Hammond" wrote in message
...
Fred,

something like this

Function SheetExists(strName As String) As Boolean
Dim shName As Worksheet
On Error Resume Next
Set shName = Sheets(strName)
On Error GoTo 0
SheetExists = Not shName Is Nothing
End Function

Robin Hammond
www.enhanceddatasystems.com

"Fred Smith" wrote in message
...
I wanted to determine whether a sheet existed in the active workbook. So I
used:

On Error Goto NoPerfSheet
Sheets("Performance").Select
On Error Goto 0

However, Excel always stopped at the Sheets command, with a Subscript out
of range error.

I knew there would never be more than two sheets in the workbook, so I
got it working by using:

IF Sheets.Count = 1 Goto NoPerfSheet

However, I'm why the On Error statement was ignored.

What conditions causes VBE to ignore On Error?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 575
Default On Error Goto ignored

Don't know. Easier to build the function once and use it lots of times
though.

Robin Hammond
www.enhanceddatasystems.com

"Fred Smith" wrote in message
...
That's a workaround I hadn't thought of, and I could see using it
sometime. Buy why was my On Error Goto ignored?

--
Regards,
Fred
Please reply to newsgroup, not e-mail


"Robin Hammond" wrote in message
...
Fred,

something like this

Function SheetExists(strName As String) As Boolean
Dim shName As Worksheet
On Error Resume Next
Set shName = Sheets(strName)
On Error GoTo 0
SheetExists = Not shName Is Nothing
End Function

Robin Hammond
www.enhanceddatasystems.com

"Fred Smith" wrote in message
...
I wanted to determine whether a sheet existed in the active workbook. So
I used:

On Error Goto NoPerfSheet
Sheets("Performance").Select
On Error Goto 0

However, Excel always stopped at the Sheets command, with a Subscript
out of range error.

I knew there would never be more than two sheets in the workbook, so I
got it working by using:

IF Sheets.Count = 1 Goto NoPerfSheet

However, I'm why the On Error statement was ignored.

What conditions causes VBE to ignore On Error?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default On Error Goto ignored

Fred,

Your code runs as it should on my XL2002.

On Error GoTo NoPerfSheet
Sheets("Performance").Select
On Error GoTo 0
Exit Sub
NoPerfSheet:
MsgBox "NoPerfSheet"

--
Earl Kiosterud
mvpearl omitthisword at verizon period net
-------------------------------------------

"Fred Smith" wrote in message
...
I wanted to determine whether a sheet existed in the active workbook. So I
used:

On Error Goto NoPerfSheet
Sheets("Performance").Select
On Error Goto 0

However, Excel always stopped at the Sheets command, with a Subscript out
of range error.

I knew there would never be more than two sheets in the workbook, so I got
it working by using:

IF Sheets.Count = 1 Goto NoPerfSheet

However, I'm why the On Error statement was ignored.

What conditions causes VBE to ignore On Error?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
On Error GoTo benb Excel Programming 3 January 5th 05 01:15 AM
On Error Goto doesn't goto Paul Excel Programming 1 October 15th 04 03:51 PM
On Error Goto doesn't goto Paul Excel Programming 0 October 15th 04 03:05 PM
On error goto 0? Brian Tozer Excel Programming 10 December 29th 03 09:59 PM
On error goto 0 David Excel Programming 2 November 18th 03 01:43 PM


All times are GMT +1. The time now is 04:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"