简体   繁体   English

Excel VBA使用范围选择整个工作表

[英]Excel VBA select entire sheet using Range

I am using the following code to search through a sheet to find out how many times does the word 'example' appear. 我正在使用以下代码在工作表中进行搜索,以查找单词“ example”出现了多少次。

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

I can't seem to figure out how to iterate through the entire sheet using the Range function. 我似乎无法弄清楚如何使用Range函数遍历整个工作表。

Why do you need to iterate through the entire sheet? 为什么需要遍历整个工作表? You can just change the extend the range? 您可以更改范围吗?

A1:A10 A1:A10

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

A1:E10 A1:E10

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

Entire sheet 整张纸

count = Application.WorksheetFunction.CountIf(ActiveSheet.Cells, "example")  

Try below to look for string "example" in entire sheet. 尝试在下面查找整个工作表中的字符串“ example”。

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

using wildcards 使用通配符

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM