「VBA」IF文を使うサンプル

書式

If (条件)  Then
  some code
ElseIf (条件)  Then
  some code
Else
  some code
End If

使用例

Sub sampfunc()
    Dim cft As Integer
    cft = 456
    
    If cft = 10 Then
        Debug.Print "value is 10"
        
    ElseIf cft = 456  Then
        Debug.Print "value is 456" 
            
    Else
        Debug.Print "other value" 
            
    End If
End Sub

 

Excel VBA

Posted by arkgame