View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Code is skipping stepps

It is only an error if the system throws an error. What you have is a
potentialy expected result. An error would be something like Runtime Error:
1004 Subsctript out of range... or such. Errors halt execution. IMO you are
using Goto in a very bad way.
--
HTH...

Jim Thomlinson


"KWhamill" wrote:

The whole goal of goto in this application is Error handling. If the Find
doesn't locate "curr" then we skip the Sub "Crnc" and go to the next sub.
Here is a little bit more of it to help clear things up:

MCA <----- A Sub which finds data on the source worksheet and transfer it
to the target worksheet
With Worksheets("Entries").Rows("1:7") <-------The source worksheet
Set C = .Find(what:="Curr", LookIn:=xlValues)
If C Is Nothing Then
GoTo Vlbl <----label for The next Sub
Crnc <-------- Sub Looks for "Curr" on the source and returns
any values in that column
End If
End With
Vlbl: ValName

Sorry about the changes i'm cleaning up and making changes as i work. I
would appreciate any ideas that might make this thing work. there are several
of these
THnaks,
Karl
"Jim Thomlinson" wrote:

Goto is a very bad coding practice. What goto does is it takes you to a
different section of code. It does not return you back when that section of
code is complete. Goto statements are good for error handling or in the very
rare (and I mean extremely rare) case where it improves performance. I
personally have never had a large enough performance gain using it that I
ever put it into production code.

Perhaps a procedure call or such would be more approptiate...
--
HTH...

Jim Thomlinson


"KWhamill" wrote:

Apparently I have told the Code to skip this step I just don't know what i
did wrong:

With Worksheets("Entries").Rows("1:7")
Set Crnc = .Find(what:="Currency", LookIn:=xlValues)
If Crnc Is Nothing Then
GoTo Vlbl <--------It goes straight here
Curr <------This is the Sub it's skipping
End If
End With