Good Morning everybody
i have an cell "B6" where it has go the formulas to get the total counts however below code i would like to set the same back to zero without erasing the formulas code in the same cell
i am currently getting an error
Private Sub Workbook_SheetChange(ByVal sh As Object, ByVal Target As Range)
Dim sSheetName As String
Dim rng As Range
Dim cell As Object
With Sheets("2022")
Set rng = .Range("B11:AF33", "B6")
For Each cell In rng
If cell.Value = "ar" Then
rng.cell("B6").Value = 0
'cell.Offset(0, 1).Value = 0
Exit For
End If
Next
End With
End Sub
CodePudding user response:
Adding comment as Answer to support closing the question:
=If(Countifs( B11:AF33,"ar")>0, 0, D9*B9*B9) is the recommendation. You use an if-statement to determine if you use the formula or set the output to 0.
