Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 2637|回复: 2

[已解决]用代码标色的问题

[复制链接]
发表于 2015-5-2 12:57 | 显示全部楼层 |阅读模式
本帖最后由 李全有 于 2015-5-2 15:16 编辑

附件
标色附件.zip (278.87 KB, 下载次数: 3)
发表于 2015-5-2 14:02 | 显示全部楼层
本帖最后由 qh8600 于 2015-5-2 14:07 编辑
  1. Sub demo()
  2. Dim a, j, b, i, s
  3.     a = Cells(1, Columns.Count).End(1).Column
  4.     For j = 2 To a Step 4
  5.         b = Cells(Rows.Count, j).End(3).Row
  6.         For i = 1 To b
  7.             If Cells(i, j) = 0 Then x = Cells(i, j + 1)
  8.         Next
  9.         For i = 1 To b
  10.             If Cells(i, j + 1) = x Then
  11.                 If IsEmpty(s) Then
  12.                     Set s = Cells(i, j + 1)
  13.                 Else
  14.                     Set s = Union(s, Cells(i, j + 1))
  15.                 End If
  16.             End If
  17.         Next
  18.     Next
  19.     Cells.Interior.ColorIndex = xlNone
  20.     s.Interior.ColorIndex = 6
  21. End Sub
复制代码
附件楼下
回复

使用道具 举报

发表于 2015-5-2 14:08 | 显示全部楼层    本楼为最佳答案   
标色附件.rar (44.05 KB, 下载次数: 7)

评分

参与人数 1 +1 收起 理由
李全有 + 1 很给力!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-14 11:59 , Processed in 0.434455 second(s), 15 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表