Perils of GoTo

One would think from reading the above, that "GoTo" is as evil as merging cells.

I KNOW from personal experience that it is not.

I use "GoTo" lots, and the folks I make my little toys for think I'm a genius.
.
.
.
.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I remember using Goto in Basic class in the 11th grade...1988!

It was a cool tool, but even then it could be tricky with the simplest programs. If you program wasn't working right, it was hard to find out just where the problem was because the gotos had the code going all over the place and stuff would happen so quickly, you couldn't see from the output exactly where the problem began!

It's nice to have things like message boxes that you can place throughout code to tell you what an error is or give you progress checks along the way. I've used them in some macros before.

I haven't the experience to say that I've used VBA and other programming code to it's fullest, but certainly the ability is out there to accomplish just about anything you can think up. Every week, I'm learning a new function that I've never heard of before...especially from this board (KUDOS TO THE BOARD!!) The code that gets thrown around this board is a little deep for me, but I fully intend to start learning it and trying it out!

Certainly, the FOR, WHILE and IF loops in Norie's link provide some interesting alternatives and the code was shorter (dare I say more "elegant") than the BASIC code that it replaced.

Thanks for everything!
Max
 
Certainly, the FOR, WHILE and IF loops in Norie's link provide some interesting alternatives and the code was shorter (dare I say more "elegant") than the BASIC code that it replaced.

I agree. But I can't justify spending hours figuring out a loop to deal with a condition when a fifteen minute GOTO statement will solve the problem. I try to keep my GOTOs in check, though.
 
Is the code working?

You may need to add the line:

Code:
On Error GoTo JurassicParkII
'    ActiveEmbryo.Unprotect
    With ActiveEmbryo.Resize(120, 65)
        With .SpecialEmbryoCells(xlCellTypeDinosaur)
            .ClearGlasses
            .LockedVeryLargeGates = False
        End With
           
        End With
'    ActiveEmbryo.Protect
    On Error GoTo Dr.John>Hammond
    ChangeDate
End Sub
 
goto.jpg
 
Code:
If User = ManiacSerialKiller Then
    GoTo DarkHouse
    GoTo Kitchen
    GoTo Drawer
    ManiacSerialKiller.HasKnife = True
    GoTo Lounge
    With Victim
        .Scream = Loud
        .RunInStupidDirection = True
    End With
    ManiacSerialKiller.ConfusedByGoTos = True
    Code.Spaghetti = xlVerySpaghettiLike
    User.Terminate = True
End If
 
How about using Goto to return error handling back to Excel as in:

On Error Resume Next
'...some code
On Error Goto 0
 

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,541
Latest member
iparraguirre89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top