建立一个宏,或一个按钮输入以下代码就行了
d = 0
With ActiveSheet.Range("a5:c20")
Set c = .Find("车间", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
d = d + 1
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
msgbox d
第二种代码:
Dim b As Range
c = 0
With ActiveSheet.Range("a5:c20")
For Each b In Range("a5:c20")
Set d = b.Find("车间", LookIn:=xlValues)
If Not d Is Nothing Then
c = c + 1
End If
Next
End With
MsgBox c
太多方法了,提供两种供你。
温馨提示:内容为网友见解,仅供参考