The If Statement
If...Then...Else statement
Option Explicit
Sub IFStatement()
Dim w As Long
' w = 0 ' is redundant because its initial value is 0 (when declared).
' 1 line
' If it is a boolean:
If ActiveSheet.Cells(58, 11).Value = False Then w = 3
'If CStr(ActiveSheet.Cells(58, 11).Value) = "FALSE" Then w = 3
' Case-insensitive
'If StrComp(CStr(ActiveSheet.Cells(58, 11).Value), "FaLSe", vbTextCompare) = 0 Then w = 3
' If it is a string ('FALSE):
'If ActiveSheet.Cells(58, 11).Value = "FALSE" Then w = 3
' Case-insensitive
'If StrComp(ActiveSheet.Cells(58, 11).Value, "FaLSe", vbTextCompare) = 0 Then w = 3
' 3 lines Another way to write the If statement:
' If ActiveSheet.Cells(58, 11).Value = False Then ' finishes with 'Then'
' w = 3
' End If
MsgBox w
End Sub
.value = Falseas you want to compare against a boolean value not a string containing the word False.