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 に答える