Private Sub Worksheet_Change(ByVal Target As Range)
Dim X As Long, CellVal As Variant, Digit As Range
' Checking only [C9]
If Target.Address = Me.Range("C9").Address Then
CellVal = Target.Value
If CellVal Like "*[!0-9]*" Then
MsgBox "The value you entered is not valid!", vbCritical
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
Else
Application.ScreenUpdating = False
Rows("2:6").Interior.ColorIndex = 0
For X = 0 To CellVal - 1
With Range("B2").Offset(, 4 * X)
.Resize(5, 3).Interior.ColorIndex = 1
.Offset(1, 1).Resize(3, 1).Interior.ColorIndex = 0
End With
Next
Application.ScreenUpdating = True
End If
End If
End Sub