Excel精英培训网

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

[已解决]包含则填充红色

[复制链接]
发表于 2016-7-23 15:51 | 显示全部楼层 |阅读模式
本帖最后由 天上的云pc 于 2016-7-23 19:33 编辑

包含则填充红色
最佳答案
2016-7-23 18:42
  1. Sub Macro1()
  2. On Error Resume Next
  3. Dim arr, d, i&, j%, c As Range
  4. [g16:at25].Interior.ColorIndex = xlNone
  5. For Each c In [g16:at25]
  6.     Set d = CreateObject("scripting.dictionary")
  7.     arr = c.Offset(-12, -5).Resize(11, 4)
  8.     For i = UBound(arr) To 1 Step -1
  9.         For j = UBound(arr, 2) To 1 Step -1
  10.             d(arr(i, j)) = ""
  11.             If d.Count > 6 Then GoTo line100
  12.         Next
  13.     Next
  14. line100:
  15.     If d.exists(c.Value) Then c.Interior.ColorIndex = 3
  16. Next
  17. End Sub
复制代码

包含则填充红色2.zip

10.57 KB, 下载次数: 13

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2016-7-23 17:10 | 显示全部楼层
请确认你附件的内容跟你的描述是否相符。
回复

使用道具 举报

发表于 2016-7-23 18:22 | 显示全部楼层
  1. Sub Macro1()
  2. On Error Resume Next
  3. Dim arr, d, i&, j%, c As Range
  4. Set d = CreateObject("scripting.dictionary")
  5. Set c = Application.InputBox("请用鼠标选中数据区域一个单元格", Type:=8)
  6. arr = c(1).Offset(-12, -5).Resize(11, 4)
  7. For i = UBound(arr) To 1 Step -1
  8.     For j = UBound(arr, 2) To 1 Step -1
  9.         d(arr(i, j)) = ""
  10.         If d.Count > 6 Then GoTo line100
  11.     Next
  12. Next
  13. line100:
  14. If d.exists(c(1).Value) Then c(1).Interior.ColorIndex = 3
  15. End Sub
复制代码
回复

使用道具 举报

发表于 2016-7-23 18:42 | 显示全部楼层    本楼为最佳答案   
  1. Sub Macro1()
  2. On Error Resume Next
  3. Dim arr, d, i&, j%, c As Range
  4. [g16:at25].Interior.ColorIndex = xlNone
  5. For Each c In [g16:at25]
  6.     Set d = CreateObject("scripting.dictionary")
  7.     arr = c.Offset(-12, -5).Resize(11, 4)
  8.     For i = UBound(arr) To 1 Step -1
  9.         For j = UBound(arr, 2) To 1 Step -1
  10.             d(arr(i, j)) = ""
  11.             If d.Count > 6 Then GoTo line100
  12.         Next
  13.     Next
  14. line100:
  15.     If d.exists(c.Value) Then c.Interior.ColorIndex = 3
  16. Next
  17. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-20 15:59 , Processed in 0.279817 second(s), 8 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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