모든 절차를 수행하기 전에 각 모듈 시트의 맨 위에 모듈 수준 선언 Option Explicit를 입력하는 것이 좋습니다. Option Explicit은 다음을 수행합니다. Dim 문을 사용하여 모든 변수를 선언합니다. 선언되지 않은 변수는 컴파일 시간에 오류를 생성합니다.
Dim score As Integer, result As String
score = Range("a1").Value
If score >= 60 Then result = "pass"
Range("b1").Value = result
if then else를 통해 거짓일때 실행하는 문구를 추가할 수 있다.
A1셀 값이 60이상이면 B1셀에 pass를
A1셀 값이 60미만이면 B1셀에 fail을 입력한다.
Dim score As Integer, result As String
score = Range("a1").Value
If score >= 60 Then
result = "pass"
Else
result = "fail"
End If
Range("b1").Value = result