Cal*_*ins 2 excel formatting vba excel-vba
我的Excel电子表格包含一列,其行可以包含值0,1或2.我的VBA代码对0s 的数量(特别是非1或的值2)求和,并将计数放入下面的单元格中.这似乎运行正常,因为最后单元格的值等于0应该的s 数,但数字显示如下(应该只是9):

数字无限重复.
我的VBA代码:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("F22")) Is Nothing And Not Intersect(Target, Range("F4:F21")) Is Nothing Then
Dim count As Integer
For i = 4 To 21:
If Not Cells(i, "F").Value = 1 And Not Cells(i, "F").Value = 2 Then
count = count + 1
End If
Next i
Cells(22, "F").Value = count
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
这是VBA问题还是我的文档格式不正确?
| 归档时间: |
|
| 查看次数: |
80 次 |
| 最近记录: |