Excel在单元格中显示无限重复的值

时间:2015-01-28 18:54:12

标签: excel excel-vba formatting vba

我的Excel电子表格包含一列,其行可以包含值012。我的VBA代码汇总0 s的数量(具体而言,不是12的值),并将计数放入下面的单元格中。这似乎运行正常,因为最后单元格的值等于0 s的数量,但数字显示如下(应该只是9):< / p>

Infinite Numbers

数字无限重复。

我的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

这是VBA问题还是我的文档格式不正确?

1 个答案:

答案 0 :(得分:5)

我认为您已使用Horizo​​ntal:alignment Fill格式化单元格。

相关问题