LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default On Error Resume Next question

Hi Alice

Thanks for the feedback.

I guess VBA is one of those things where you just keep learning new tricks
all the time ;-)

With regard to Bob's code:

' set the variable dType to blank (a known state, not carried forward from
previous test(s))
dType = ""
' switch on Error Trapping - so that the code will continue to the next line
whatever happens
On Error Resume Next
' set dType to the Validation Type for the cell ... which will cause an
error if there isn't any
dType = .Validation.Type
' switch off Error Trapping ... and, in this case,is quite nicely the *next
line* for the Resume Next
On Error GoTo 0
' test the dType variable which will be blank if there was no Validation
(having pre-set it above)
If dType < "" Then

Hope that makes it clearer.

You should always keep the error trapping range to a minimum as other errors
could be missed and, although it means your code won't fail, you may not get
the results you expect.

Regards

Trevor


wrote in message
ups.com...
On Sep 21, 4:51 pm, "Trevor Shuttleworth"
wrote:
Alice

the piece of code shown is missing an End If inside the For Loops.
Probably
won't help ;-)

You should surround the code that can generate the error with On Error
Statements

On Error Resume Next ' switch on error trapping
' code that can produce the error
On Error Goto 0 ' switch off error trapping
' test for error condition

As it stands, the first time you go through the loop you switch on error
trapping and it stays on

Regards

Trevor

wrote in message

ups.com...



Thanks, Trevor. I see that Bob Phillips example had the two error
traps as you stated, but I didn't know why. I often feel that VBA is
like a foreign language where I just don't know enough words. Things
almost make sense, and after a lot of labor, I can usually get close
to what I want, but the fine details still elude me!

Alice





 
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 resume next Janis Excel Programming 1 September 19th 06 08:12 PM
Resume on Error? dan Excel Programming 1 July 24th 06 06:53 PM
On Error {...} Resume Next Edd[_2_] Excel Programming 2 March 15th 06 11:09 PM
On error resume next? question - problem Andrzej Excel Programming 13 June 3rd 05 01:02 PM
"On Error Resume Next" Question Jim[_26_] Excel Programming 1 September 20th 03 07:38 PM


All times are GMT +1. The time now is 06:04 PM.

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

About Us

"It's about Microsoft Excel"