Excel精英培训网

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

[已解决]d1.exists(dc)字典中keys不重复在这里运用错误是怎么回事?

[复制链接]
发表于 2015-3-21 22:12 | 显示全部楼层 |阅读模式
我需要将A列中单据号,如果B列有,就作色,先是利用KEY不重复,提取单取号,再利用KEY不重复,如果存在,则作色?怎么不正确呢? 记号.png 记号.rar (12.7 KB, 下载次数: 8)
发表于 2015-3-21 23:14 | 显示全部楼层
回复

使用道具 举报

发表于 2015-3-22 07:45 | 显示全部楼层    本楼为最佳答案   
  1. Sub 记号()
  2. Dim d, i&, n&
  3. Set d = CreateObject("scripting.dictionary")
  4. [a:a].Interior.ColorIndex = xlNone
  5. n = Range("a65536").End(xlUp).Row
  6. With CreateObject("VBscript.regexp")
  7.     .Global = True
  8.     .Pattern = "\d{10}"
  9.     For i = 2 To n
  10.         For Each m In .Execute(Cells(i, 2))
  11.             d("'" & m) = ""
  12.         Next
  13.     Next
  14. End With
  15. For i = 2 To n
  16.     If d.exists("'" & Cells(i, 1).Value) Then
  17.         Cells(i, 1).Interior.ColorIndex = 5
  18.     End If
  19. Next
  20. [d:d] = ""
  21. [d2].Resize(d.Count) = Application.Transpose(d.keys)
  22. End Sub
复制代码
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-25 01:11 , Processed in 0.305978 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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