You can't delete the contents using worksheet functions, but if D2
contains a formula, you can make the cell appear blank:
D2: =IF(B2="SD","",<your formula here)
If D2 contains a constant/user entered value, or if you really want it
blank, then you'll need to use an Event macro.
If B2 will contain a user entry, put this in the worksheet code module
(right-click the worksheet tab and choose View Code):
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If .Address(False, False) = "B2" Then _
If .Value = "SD" Then _
Range("D2").ClearContents
End With
End Sub
or, if B2 has a formula instead, put this in the worksheet code module
instead:
Private Sub Worksheet_Calculate()
If Range("B2").Value = "SD" Then _
Range("D2").ClearContents
End Sub
In article ,
"StarBoy2000" wrote:
How do I Delete Contents of D2 if B2 = "SD". Then continue through every row
in the file?
|