Excel精英培训网

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

[已解决](求助)怎么样才能快速锁定共同点?

[复制链接]
发表于 2012-9-8 11:33 | 显示全部楼层 |阅读模式
附件如右 查询共同点附件.rar (7.73 KB, 下载次数: 10)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2012-9-8 12:20 | 显示全部楼层    本楼为最佳答案   
  1. Sub test()
  2.     Dim arr, d1, d2
  3.     Dim i As Long, j As Long, x As Long
  4.     Cells.Interior.ColorIndex = xlNone
  5.     i = Cells(Rows.Count, 1).End(xlUp).Row
  6.     j = Cells(1, Columns.Count).End(xlToLeft).Column
  7.     arr = Range(Cells(1, 1), Cells(i, j))
  8.     Set d1 = CreateObject("scripting.dictionary")
  9.     Set d2 = CreateObject("scripting.dictionary")
  10.     For i = 1 To UBound(arr)
  11.         d1.RemoveAll
  12.         d2.RemoveAll
  13.         For x = (j + 1) / 3 + 1 To (j + 1) * 2 / 3 - 1
  14.             d1(arr(i, x)) = ""
  15.         Next
  16.         For x = (j + 1) * 2 / 3 + 1 To UBound(arr, 2)
  17.             d2(arr(i, x)) = ""
  18.         Next
  19.         For x = 1 To (j + 1) / 3 - 1
  20.             If d1.exists(arr(i, x)) And d2.exists(arr(i, x)) Then
  21.                 Cells(i, x).Interior.ColorIndex = 6
  22.             End If
  23.         Next
  24.     Next
  25.     Set d1 = Nothing
  26.     Set d2 = Nothing
  27. End Sub
复制代码

评分

参与人数 1 +1 收起 理由
yesddd + 1 很给力!

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-1 18:09 , Processed in 1.130274 second(s), 17 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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