Go To Statement

elgringo56

Well-known Member
Joined
Apr 15, 2002
Messages
869
I dont understand the go to statement, but I need to use it. I am running inside a next i loop. I am testing a cell for a blank condition using a Select Case Statement. If I find the cell is blank, I want to go to the "next i" end of the loop and bypass a lot of code. but I cant seem to figgure out how this works. Can anyone help me on this?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
When using goto, you have to have labels. For instance:

Sub test()
GoTo blah
MsgBox "no"
blah:
MsgBox "yes"
End Sub

Would give you the message "yes" since you told it to goto the label "blah."
 
Upvote 0
ok, given the below, can I put a lable above the next i and then go to that?
Select Case Range("X1").Value
Case Is = ""
GoTo
Case Else
ActiveSheet.Shapes("Group 20").Visible = False
A bunch more code
Next i
 
Upvote 0
Something isn't working right here. When I put in the lable, I used Blank:, I got a compile error, next without for. The loop worked prior to inserting the lable.
 
Upvote 0
For i = 1 To LoopRange
Range("AA6").Select
Selection.Copy
Range("AB6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("AA9").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Range("AB5:AB6"), CopyToRange:=Range("AP9:BB9"), Unique:=False
Select Case Range("X1").Value
Case Is = ""
GoTo Blank
Case Else
Range("BE10:BE61").Select
Selection.Copy
Range("BB10:BB61").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("AP9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents
Range("AP9").Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.ClearContents
Range("AP10").Select
ActiveCell.CurrentRegion.Select
Selection.Copy
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("AP10:BB509").Select
Selection.ClearContents
Next i
 
Upvote 0
I don't see the label anywhere in that code.

There should be a Blank: somewhere.
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,291
Members
448,564
Latest member
ED38

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