なんか、前にも有ったような課題ですね
Sub Test()
Dim i As Long, myArea As Range
Dim myRang As Range, c As Range, cc As Range
Dim SV As Long, flg As Boolean
Application.ScreenUpdating = False
'作業行挿入
Rows("1:1").Insert
'作業列挿入
Columns("A:A").Insert
Range("B13:N522").Clear
For i = 1 To Range("P2").Value
Range("B2:N12").Copy Cells(i * 12 + 2, "B")
Set myArea = Cells(i * 12 + 2, "B").Resize(11, 13).SpecialCells(2)
Cells(3, i + 15).Copy Cells(i * 12 + 1, "B")
For Each myRang In myArea.Areas
SV = Val(Cells(i * 12 + 1, "B").Value)
For Each c In myRang.Cells
If Val(c.Value) = SV Then
For Each cc In c.Cells(0, 0).Resize(3, 3)
If cc.Row Mod 6 <> 1 And cc.Column Mod 7 <> 1 _
And c.Address <> cc.Address Then
If Abs(Val(c.Value) - Val(cc.Value)) <= 1 Then
cc.Interior.Color = vbRed
flg = True
End If
End If
Next
If flg = True Then
c.Interior.Color = vbRed
Else
c.Interior.Color = vbYellow
End If
End If
flg = False
Next
Next
Next
'作業行削除
Rows("1:1").Delete
'作業列削除
Columns("A:A").Delete
Application.ScreenUpdating = True
End Sub