Hi Bill,
Jim's code represents an event procedure. Event procedures are triggered by
an event and do not need to be called or run.
For more information on event procedures, see Chip Pearson at:
http://www.cpearson.com/excel/events.htm
Jim's code ran without problem for me and cleared the required ranges in
response to zero values in column C.
However, as your zero values occur as the result of formulas, I think that
you will need to use the Calculate event. Try, therefore, pasting the
following code into the sheet module:
'===============>>
Private Sub Worksheet_Calculate()
Dim Rng As Range, RngZero As Range
Dim fAddress As String
Application.EnableEvents = False
On Error Resume Next
Set Rng = Range("C1:C8000").SpecialCells(xlFormulas)
On Error GoTo 0
If Not Rng Is Nothing Then
With Rng
Set RngZero = Rng.Find(What:=0, _
After:=Rng(1), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext)
If Not RngZero Is Nothing Then
fAddress = RngZero.Address
Do
RngZero.Offset(, 1).Resize(1, _
Columns.Count - 3).ClearContents
Set RngZero = .FindNext(RngZero)
Loop While Not RngZero Is Nothing _
And RngZero.Address <> fAddress
End If
End With
End If
Application.EnableEvents = True
End Sub
'<<===============
As with Jim's code, this is worksheet event code and should be pasted into
the worksheets's code module (not a standard module and not the workbook's
ThisWorkbook module):
*******************************************
Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.
*******************************************