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?
 
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
Blank:
Next i
 
Upvote 0

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
No, goto can be used in a for i loop. The problem is with the cases, take them out and you will see that the "goto" works just fine.
 
Upvote 0
TestCell = Range("AP10").Value
If TestCell Is "" Then GoTo Blank
End If

Is there any possibility this would work? Again, I am trying something I know nothing about
 
Upvote 0

Forum statistics

Threads
1,214,976
Messages
6,122,539
Members
449,088
Latest member
RandomExceller01

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