![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 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?
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
|
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." |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
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 |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
|
Yes, you can put a label above the "next i" and goto that.
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
Thanks, I will give it a try
|
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
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.
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
|
Copy/paste the code you have written.
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
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 |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Apr 2002
Location: Puerto Vallarta, Mexico
Posts: 869
|
I put the lable right above the next i statement
|
|
|
|
|
|
#10 |
|
Board Regular
Join Date: Apr 2002
Location: Redmond, WA
Posts: 636
|
I don't see the label anywhere in that code.
There should be a Blank: somewhere. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|