指定したキーワードを含まない列を非表示にする

Visual Basic for Applications

Sub Macro()
  Dim KeyWord As Variant
  Dim srrr As Integer '起点セルの行番号 Starting
  Dim sccc As Integer '起点セルの列番号 Starting
  Dim occc As Integer '検索セルの列番号 Objective
  Dim sheet As Integer
  Dim EndRow As Integer
  Dim cnt As Integer
  Dim iii As Integer
  Dim rrr As Integer
  KeyWord = Array("ExampleWord01", "ExampleWord02", "ExampleWord03")
  srrr = 1
  sccc = 1
  occc = 1
  sheet = 1
  EndRow = Worksheets(sheet).Cells(srrr, sccc).End(xlDown).Row
  rrr = srrr
  Do Until EndRow < rrr
    cnt = 0
    For iii = 0 To UBound(KeyWord)
      If InStr(Worksheets(sheet).Cells(rrr, occc), KeyWord(iii)) <> 0 Then
        cnt = 1
        Exit For
      End If
    Next iii
    If cnt = 0 Then
      Rows(rrr).Select
      Selection.EntireRow.Hidden = True '削除の場合はSelection.Delete Shift:=xlUp。但し行番号が変わるためrrr = rrr + 1の位置を変更する
    End If
    rrr = rrr + 1
  Loop
End Sub