Excel精英培训网

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

[已解决]谢谢爱疯老师,双击指定列中的任意单元格后,在其它单元格内以红色标识出来

[复制链接]
发表于 2011-4-30 11:20 | 显示全部楼层 |阅读模式
本帖最后由 lhj323323 于 2011-5-1 14:59 编辑

老师:
需求如题,请问怎么写,谢谢了。
最佳答案
2011-4-30 12:11
双击同色2.rar (14.05 KB, 下载次数: 25)

双击同色.rar

12.15 KB, 下载次数: 8

发表于 2011-4-30 11:28 | 显示全部楼层
回复

使用道具 举报

发表于 2011-4-30 12:11 | 显示全部楼层    本楼为最佳答案   
双击同色2.rar (14.05 KB, 下载次数: 25)
回复

使用道具 举报

发表于 2011-4-30 12:36 | 显示全部楼层
  1. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  2. Dim c As Range
  3. If Target.Count > 1 Then Exit Sub
  4. If Target.Row > 2 Then
  5.     If Target.Column = 6 Or Target.Column = 14 Then
  6.         With Columns(Target.Column)
  7.             .Interior.ColorIndex = xlNone
  8.             Target.Interior.ColorIndex = 6
  9.             Cancel = True
  10.             Set c = Columns(Target.Column).Find(Target, , , 1)
  11.             If Not c Is Nothing Then
  12.                 Do
  13.                     c.Interior.ColorIndex = 6
  14.                     Set c = .FindNext(c)
  15.                 Loop While Not c Is Nothing And c.Address <> Target.Address
  16.             End If
  17.         End With
  18.     End If
  19. End If
  20. End Sub
复制代码
回复

使用道具 举报

 楼主| 发表于 2011-4-30 20:08 | 显示全部楼层
回复 殘剑 的帖子

残剑老师:
您写的程序,没有测试成功:
比如A营业部在F列和N列都有几处出现过的话,当我用鼠标选择其中一个营业部双击后,只能在同列的几处显示,跨列的记录则没有显示。
回复

使用道具 举报

发表于 2011-4-30 23:27 | 显示全部楼层
跟帖学习了
回复

使用道具 举报

 楼主| 发表于 2011-5-1 15:00 | 显示全部楼层
回复 tony3 的帖子

谢谢指点。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-27 11:35 , Processed in 0.437771 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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