存在运行时错误6'溢出',其中变量声明为整数。
Sub yahoo()
Dim n As Integer
Range("A:a").AutoFilter Field:=1, Criteria1:="*yahoo*"
n = Range("a:a").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants).Count
Range("c1") = n
End Sub
答案 0 :(得分:0)
将整数替换为长整数(有关VBA数据类型的更多内容:https://msdn.microsoft.com/en-us/library/47zceaw7.aspx)
Sub yahoo()
Dim n As Long
Range("A:a").AutoFilter Field:=1, Criteria1:="*yahoo*"
n = Range("a:a").SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants).Count
Range("c1") = n
End Sub