2

我正在使用以下代码在工作表中搜索,以了解“示例”一词出现了多少次。

count = Application.WorksheetFunction.CountIf(Range("A1:A10"), "example")

我似乎无法弄清楚如何使用 Range 函数遍历整个工作表。

4

2 回答 2

3

为什么需要遍历整个工作表?您可以更改扩展范围吗?

A1:A10

count = Application.WorksheetFunction.CountIf(Range("A1:A10"), "example")

A1:E10

count = Application.WorksheetFunction.CountIf(Range("A1:E10"), "example")

整张纸

count = Application.WorksheetFunction.CountIf(ActiveSheet.Cells, "example")  
于 2013-11-01T19:59:16.157 回答
1

尝试在下面查找整个工作表中的字符串“示例”。

Count = Application.WorksheetFunction.CountIf(Cells, "example")

使用通配符

Count = Application.WorksheetFunction.CountIf(Cells, "*example*")

于 2013-11-01T19:51:42.127 回答