对应Excle整数填充颜色

  
   
Sub Auto()
'
' 宏1 宏
'

'
Dim x As Byte

Dim y As Byte

Dim MyVar As Integer

Dim i As Byte

x = 1


Do While Cells(x, 1) <> ""
 
 y = 1

  Do While Cells(x, y) <> ""
      


   MyVar = Cells(x, y).Value

   Select Case MyVar
      Case 1
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 192
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
      Case 2
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 255
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
      Case 3
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 49407
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
     Case 4
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 65535
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
     Case 5
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 5296274
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
       Case 6
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 5287936
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
       Case 7
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 15773696
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
       Case 8
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 12611584
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
       Case 9
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 6299648
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
       Case 10
         With Cells(x, y).Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 10498160
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
      Case Else
        With Cells(x, y).Interior
        .Pattern = xlNone
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
     
   End Select 
    
  
  y = y + 1
  
  Loop
 
x = x + 1

Loop 


End Sub
   
  
 

猜你喜欢

转载自blog.csdn.net/star65806841/article/details/82388943
今日推荐