Range.Interior.Pattern:セルのパターン(網掛け)を設定する

Excel VBA リファレンス

スポンサードリンク

セルのパターン(網掛け)を設定する

サンプルコード
Option Explicit

'このプロシージャから実行してください。
Sub main()
  'セルのパターンを取得する
  With Worksheets("Sheet1")
    If Cells(3, 1).Interior.Pattern = xlPatternNone Then
      Debug.Print ("セルのパターンは xlPatternNone です")
    Else
      Debug.Print ("セルのパターンは xlPatternNone 以外です")
    End If
  End With
  
  'セルにパターンを設定する
  With Worksheets("Sheet1")
    Cells(1, 1).Interior.Pattern = xlPatternAutomatic
    Cells(1, 2).Value = "xlPatternAutomatic"
    
    Cells(2, 1).Interior.Pattern = xlPatternChecker
    Cells(2, 2).Value = "xlPatternChecker"

    Cells(3, 1).Interior.Pattern = xlPatternCrissCross
    Cells(3, 2).Value = "xlPatternCrissCross"

    Cells(4, 1).Interior.Pattern = xlPatternDown
    Cells(4, 2).Value = "xlPatternDown"

    Cells(5, 1).Interior.Pattern = xlPatternGray8
    Cells(5, 2).Value = "xlPatternGray8"

    Cells(6, 1).Interior.Pattern = xlPatternGray16
    Cells(6, 2).Value = "xlPatternGray16"

    Cells(7, 1).Interior.Pattern = xlPatternGray25
    Cells(7, 2).Value = "xlPatternGray25"

    Cells(8, 1).Interior.Pattern = xlPatternGray50
    Cells(8, 2).Value = "xlPatternGray50"

    Cells(9, 1).Interior.Pattern = xlPatternGray75
    Cells(9, 2).Value = "xlPatternGray75"

    Cells(10, 1).Interior.Pattern = xlPatternGrid
    Cells(10, 2).Value = "xlPatternGrid"

    Cells(11, 1).Interior.Pattern = xlPatternHorizontal
    Cells(11, 2).Value = "xlPatternHorizontal"

    Cells(12, 1).Interior.Pattern = xlPatternLightDown
    Cells(12, 2).Value = "xlPatternLightDown"

    Cells(13, 1).Interior.Pattern = xlPatternLightHorizontal
    Cells(13, 2).Value = "xlPatternLightHorizontal"

    Cells(14, 1).Interior.Pattern = xlPatternLightUp
    Cells(14, 2).Value = "xlPatternLightUp"

    Cells(15, 1).Interior.Pattern = xlPatternLightVertical
    Cells(15, 2).Value = "xlPatternLightVertical"

    Cells(16, 1).Interior.Pattern = xlPatternNone
    Cells(16, 2).Value = "xlPatternNone"

    Cells(17, 1).Interior.Pattern = xlPatternSemiGray75
    Cells(17, 2).Value = "xlPatternSemiGray75"

    Cells(18, 1).Interior.Pattern = xlPatternSolid
    Cells(18, 2).Value = "xlPatternSolid"

    Cells(19, 1).Interior.Pattern = xlPatternUp
    Cells(19, 2).Value = "xlPatternUp"

    Cells(20, 1).Interior.Pattern = xlPatternVertical
    Cells(20, 2).Value = "xlPatternVertical"
  End With

  'セルのパターンを取得する
  With Worksheets("Sheet1")
    If Cells(3, 1).Interior.Pattern = xlPatternNone Then
      Debug.Print ("セルのパターンは xlPatternNone です")
    Else
      Debug.Print ("セルのパターンは xlPatternNone 以外です")
    End If
  End With
End Sub

処理結果
セルのパターン(網掛け)設定
スポンサードリンク
関連カテゴリー
セル操作 / 関数・ステートメント索引(R)