excel vba: 统计单元格区域公式中包含某个字符串的单元格个数
1个回答
2013-05-21
展开全部
如果光这个功能,用公式就可以的 =countif(a5:C20,"*车间*")用VBA的话,是这样子 Sub GetNum()
Dim Rng As Range, TempRng As Range
Dim Cnt%
Set Rng = Sheets("你的表名").Range("A5:C20")
For Each TempRng In Rng
If InStr(1, TempRng.Value, "车间") > 0 Then Cnt = Cnt + 1
Next
MsgBox "有“车间”字符的单元格个数为:" & Cnt
End Sub
Dim Rng As Range, TempRng As Range
Dim Cnt%
Set Rng = Sheets("你的表名").Range("A5:C20")
For Each TempRng In Rng
If InStr(1, TempRng.Value, "车间") > 0 Then Cnt = Cnt + 1
Next
MsgBox "有“车间”字符的单元格个数为:" & Cnt
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询