「Excel VBA」if文にネストの構造のサンプル

2021年1月28日

書式

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
If 条件式1 Then
If 条件式2 Then
If 条件式1 Then If 条件式2 Then
If 条件式1 Then
  If 条件式2 Then

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Sub sampleFunc()
Dim xx,yy As Integer
xx = 67
yy = 78
If xx = 67 Then
If yy = 78 Then
Debug.Print "nest sample"
End If
End If
End Sub
Sub sampleFunc() Dim xx,yy As Integer xx = 67 yy = 78 If xx = 67 Then If yy = 78 Then Debug.Print "nest sample" End If End If End Sub
Sub sampleFunc()
    Dim xx,yy As Integer
    xx = 67
    yy = 78
    
    If xx = 67 Then
        If yy = 78 Then
            Debug.Print "nest sample"
        End If
    End If
End Sub

 

Excel VBA

Posted by arkgame