Sub 连续标志奇偶()
Dim R As Integer, i As Integer, bz As Integer, num As Integer
R = ActiveSheet.Range("A65536").End(xlUp).Row
bj = Range("a1").Value Mod 2: num = 1
For i = 2 To R
If bj = Cells(i, 1) Mod 2 Then num = num + 1 Else bj = Cells(i, 1) Mod 2: num = 1
If num >= 6 Then Cells(i, 2) = Str(num)
Next i
End Sub
请大神帮忙改为连续6个或以上的偶数才标示,奇数不标示,谢谢
这个是可以做到连续的六个或以上偶数标示,但为什么在我在手动打字上去的能标示,而用公式自动计算的数据无法标示,比如我在A1输入公式=IF(C1=D1,1,"")向下拉,这样的出来连续六个空格时VBA没法标6
追答空格 又不是数字,
=IF(C1=D1,1,0)
你写成 0 就是数字了
奇数的还是会标出来,请帮忙把奇数的标示删掉,谢谢
追答If bj = Cells(i, 1) Mod 2 Then num = num + 1 Else bj = Cells(i, 1) Mod 2: num = 1
改
If Cells(i, 1) Mod 2=0 Then
num = num + 1
Else
num = 1
end if