大家早上好
我有一個單元格“B6”,其中有公式來獲得總計數但是下面的代碼我想將其設定回零而不洗掉同一單元格中的公式代碼
我目前遇到錯誤
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
uj5u.com熱心網友回復:
添加評論作為答案以支持關閉問題:
=If(Countifs( B11:AF33,"ar")>0, 0, D9*B9*B9)是建議。您使用 if 陳述句來確定您是使用公式還是將輸出設定為0.
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/411627.html
標籤:
下一篇:用VBa關閉excel應用程式
