Excelで選択したエリアを一行おきに選択し、色を設定します。
デフォルト環境で設定するのが面倒くさいので作成した一行版の市松模様版です。
Sub SelectCheckerboardPattern()
Dim rng As Range
Dim cell As Range
Dim newSelection As Range
Dim rowIndex As Integer, colIndex As Integer
' 選択範囲を取得
On Error Resume Next
Set rng = Selection
On Error GoTo 0
' 範囲が選択されていない場合、エラーを表示
If rng Is Nothing Then
MsgBox "セル範囲を選択してください。", _
vbExclamation, "エラー"
Exit Sub
End If
' 市松模様(チェッカーパターン)に選択
For rowIndex = 1 To rng.Rows.Count
For colIndex = 1 To rng.Columns.Count
If (rowIndex + colIndex) Mod 2 = 0 Then
Set cell = rng.Cells(rowIndex, colIndex)
If newSelection Is Nothing Then
Set newSelection = cell
Else
Set newSelection = Union(newSelection, cell)
End If
End If
Next colIndex
Next rowIndex
' 選択を適用
If Not newSelection Is Nothing Then
newSelection.Select
End If
MsgBox "市松模様(チェッカーパターン)で選択しました!", _
vbInformation, "完了"
End Sub
エリアを選択し・・・
実行すると市松模様的に選択した状態になるので・・・
カラーパレットで任意の色を設定。
シンプルな動きの方が応用が利きますね。