Try this
Sub Demo()
Application.Calculation = xlCalculationAutomatic 'set calculation mode to automatic
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet2") 'change Sheet2 to your data sheet
'check condition for B4=FALSE
If Not ws.Range("B4") Then ws.Range("D3").ClearContents
Application.Calculation = xlCalculationManual 'set calculation mode to manual
End Sub
NOTE : Use of SELECT
should be avoided. See this for details.
EDIT : As @Slai pointed out in the comment below, If Not ws.Range("B4")
will return TRUE
if text of Range("B4")
is either False
, 0
or
(blank). So either you'll have to make sure that only TRUE
and FLASE
are entered in Cell B4
else add another IF
condition in code to check whether the entered value is BOOLEAN
or not. Thus update above code as
Sub Demo()
Application.Calculation = xlCalculationAutomatic 'set calculation mode to automatic
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet2") 'change Sheet2 to your data sheet
If VarType(ws.Range("B4")) = vbBoolean Then 'check whether the cell value is boolean
'check condition for B4=FALSE
If Not ws.Range("B4") Then ws.Range("D3").ClearContents
End If
Application.Calculation = xlCalculationManual 'set calculation mode to manual
End Sub