WorksheetFunction オブジェクト (Excel)

Visual Basic から呼び出すことができる Excel ワークシート関数のコンテナーとして使用されます。

WorksheetFunction オブジェクトを戻すには、Application オブジェクトの WorksheetFunction プロパティを使用します。

次の使用例は、 Min ワークシート関数をセル範囲 A1:C10 に適用した結果を表示します。

Set myRange = Worksheets("Sheet1").Range("A1:C10") 
answer = Application.WorksheetFunction.Min(myRange) 
MsgBox answer

この例は、CountA ワークシート関数を使用して、列 A 内のセルのうち値が含まれるセルの数を確認します。 この例では、列 A 内の値として文字が含まれている必要があります。 この例は、列 A 内の各値に対してスペル チェックを実行し、値のスペルが誤っている場合は文字 "Wrong" を列 B に挿入し、それ以外の場合は文字 "OK" を列 B に挿入します。

Sub StartSpelling()
   'Set up your variables
   Dim iRow As Integer
   
   'And define your error handling routine.
   On Error GoTo ERRORHANDLER
   
   'Go through all the cells in column A, and perform a spellcheck on the value.
   'If the value is spelled incorrectly, write "Wrong" in column B; otherwise, write "OK".
   For iRow = 1 To WorksheetFunction.CountA(Columns(1))
      If Application.CheckSpelling( _
         Cells(iRow, 1).Value, , True) = False Then
         Cells(iRow, 2).Value = "Wrong"
      Else
         Cells(iRow, 2).Value = "OK"
      End If
   Next iRow
   Exit Sub

    'Error handling routine.
ERRORHANDLER:
    MsgBox "The spell check feature is not installed!"
    
End Sub

メソッド

プロパティ

関連項目

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。