「Excel VBA」 GoTo文でループ処理をスキップするサンプル
書式
GoTo ラベル名
使用例
Sub testFunc()
Dim n As Integer
n = 10
'Do Whileループ
Do While n < 30
'ラベルInfo
Info:
If (n = 19) Then
n = n + 3
'gotoラベル
GoTo Info
End If
'デバッグの値を出力
Debug.Print n
n = n + 3
Loop
End Sub
実行結果
10
13
16
22
25
28