| 
    
     |  | 1と入力すれば、1と入力されているセルが赤それを、24色使い 行いたい。
 行ってみた、ほぼ、完成ですが・・・
 
 調べたが、分からないので教えてください。
 
 FORループ★モジュールで全てのセルをチェックしないと、行か列が増えた時の対応
 規定外の数字はELSEを使う。
 とのことですが、使い方をおしえてください。
 
 
 Sub 数値セル塗チェック()
 Dim RowPos As Integer
 Dim ColPos As Integer
 Dim Num As Integer
 
 Set WS = Worksheets("Sheet1")
 
 'セルの指定
 RowPos = 1
 ColPos = 1
 Do
 If WS.Cells(RowPos, ColPos) = "" Then
 Exit Do
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 1 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 0, 0)
 End If
 If Num = 2 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 0, 0)
 End If
 If Num = 3 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 255, 0)
 End If
 If Num = 4 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 0, 255)
 End If
 If Num = 5 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 100, 90)
 End If
 If Num = 6 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 0, 180)
 End If
 If Num = 7 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(100, 25, 100)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 8 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 25, 100)
 End If
 If Num = 9 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 25, 0)
 End If
 If Num = 10 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 255, 100)
 End If
 If Num = 11 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(230, 25, 100)
 End If
 If Num = 12 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(29, 71, 29)
 End If
 If Num = 13 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 71, 29)
 End If
 If Num = 14 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 71, 29)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 15 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(203, 97, 17)
 End If
 If Num = 16 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(117, 107, 103)
 End If
 If Num = 17 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(140, 4, 216)
 End If
 If Num = 18 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(186, 132, 168)
 End If
 If Num = 19 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(248, 255, 159)
 End If
 If Num = 20 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(168, 242, 246)
 End If
 If Num = 21 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(247, 209, 167)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 22 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(205, 113, 133)
 End If
 If Num = 23 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(81, 48, 45)
 End If
 If Num = 24 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(252, 252, 28)
 End If
 RowPos = RowPos + 1
 Loop While Num > -1
 
 'セルの指定
 RowPos = 1
 ColPos = 2
 Do
 If WS.Cells(RowPos, ColPos) = "" Then
 Exit Do
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 1 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 0, 0)
 End If
 If Num = 2 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 0, 0)
 End If
 If Num = 3 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 255, 0)
 End If
 If Num = 4 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 0, 255)
 End If
 If Num = 5 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 100, 90)
 End If
 If Num = 6 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 0, 180)
 End If
 If Num = 7 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(100, 25, 100)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 8 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 25, 100)
 End If
 If Num = 9 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 25, 0)
 End If
 If Num = 10 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 255, 100)
 End If
 If Num = 11 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(230, 25, 100)
 End If
 If Num = 12 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(29, 71, 29)
 End If
 If Num = 13 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 71, 29)
 End If
 If Num = 14 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 71, 29)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 15 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(203, 97, 17)
 End If
 If Num = 16 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(117, 107, 103)
 End If
 If Num = 17 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(140, 4, 216)
 End If
 If Num = 18 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(186, 132, 168)
 End If
 If Num = 19 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(248, 255, 159)
 End If
 If Num = 20 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(168, 242, 246)
 End If
 If Num = 21 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(247, 209, 167)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 22 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(205, 113, 133)
 End If
 If Num = 23 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(81, 48, 45)
 End If
 If Num = 24 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(252, 252, 28)
 End If
 RowPos = RowPos + 1
 Loop While Num > -1
 
 'セルの指定
 RowPos = 1
 ColPos = 3
 Do
 If WS.Cells(RowPos, ColPos) = "" Then
 Exit Do
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 1 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 0, 0)
 End If
 If Num = 2 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 0, 0)
 End If
 If Num = 3 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 255, 0)
 End If
 If Num = 4 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 0, 255)
 End If
 If Num = 5 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 100, 90)
 End If
 If Num = 6 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 0, 180)
 End If
 If Num = 7 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(100, 25, 100)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 8 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 25, 100)
 End If
 If Num = 9 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 25, 0)
 End If
 If Num = 10 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 255, 100)
 End If
 If Num = 11 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(230, 25, 100)
 End If
 If Num = 12 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(29, 71, 29)
 End If
 If Num = 13 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(255, 71, 29)
 End If
 If Num = 14 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(0, 71, 29)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 15 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(203, 97, 17)
 End If
 If Num = 16 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(117, 107, 103)
 End If
 If Num = 17 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(140, 4, 216)
 End If
 If Num = 18 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(186, 132, 168)
 End If
 If Num = 19 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(248, 255, 159)
 End If
 If Num = 20 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(168, 242, 246)
 End If
 If Num = 21 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(247, 209, 167)
 End If
 Num = WS.Cells(RowPos, ColPos)
 If Num = 22 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(205, 113, 133)
 End If
 If Num = 23 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(81, 48, 45)
 End If
 If Num = 24 Then
 WS.Cells(RowPos, ColPos).Interior.Color = RGB(252, 252, 28)
 End If
 RowPos = RowPos + 1
 Loop While Num > -1
 
 |  |