根据Excel中的某一列的分别加颜色

   1:  Sub Macro1()
   2:       Dim i As Integer
   3:       Dim x As String
   4:       For i = 1 To Sheet1.UsedRange.Rows.Count
   5:          With Sheet1.Rows(i).Interior
   6:               x = Cells(i, 3)
   7:               If x = "是" Then
   8:                  Call Macro2(i, 3, 15773696)
   9:               ElseIf x = "否" Then
  10:                  Call Macro2(i, 3, 5296274)
  11:               End If
  12:           End With
  13:       Next
  14:   End Sub
  15:   
  16:  Sub Macro2(x As Integer, y As Integer, colorIndex As Long)
  17:      Range(Cells(x, y), Cells(x, y)).Select
  18:      With Selection.Interior
  19:          .Pattern = xlSolid
  20:          .PatternColorIndex = xlAutomatic
  21:          .color = colorIndex
  22:          .TintAndShade = 0
  23:          .PatternTintAndShade = 0
  24:      End With
  25:      Range("G18").Select
  26:  End Sub
  27:   
  28:   
  29:  
  30:  Sub Macro1()
  31:       Dim i As Long
  32:       Dim x As String
  33:       Columns(3).Interior.ColorIndex = xlNone
  34:       For i = 1 To Sheet1.UsedRange.Rows.Count
  35:          With Sheet1.Rows(i).Interior
  36:               x = Cells(i, 3)
  37:               If x = "是" Then
  38:               Cells(i, 3).Interior.ColorIndex = 5
  39:               End If
  40:           End With
  41:       Next
  42:   End Sub

转载于:https://www.cnblogs.com/pnljs/archive/2013/03/08/2949695.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值