Excel精英培训网

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

[已解决](求助)再请amulee老师

[复制链接]
发表于 2010-1-4 15:47 | 显示全部楼层 |阅读模式

 

NPGatQdX.rar (8.55 KB, 下载次数: 1)

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2010-1-4 15:52 | 显示全部楼层

测试了一下,D2和E2不会清空。

我的代码是根据单元格填充色进行判断的,所以请不要将那两个单元格填充浅黄色。

回复

使用道具 举报

 楼主| 发表于 2010-1-4 16:05 | 显示全部楼层

如何修改代码实现点重置数据时,D2和E2和黄色单元格数据一起清空呢?D2单元格是输入参评人数的,e2是输入日期的。

谢谢老师。

[此贴子已经被作者于2010-1-4 16:08:21编辑过]
回复

使用道具 举报

发表于 2010-1-4 16:09 | 显示全部楼层    本楼为最佳答案   

原来你要清空啊,正好弄反了,呵


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count = 1 Then
        If Target.Address = "$G$2" Then
            If MsgBox("是否重置数据?", vbYesNo) = vbYes Then
                Dim MyCell As Range
                Application.ScreenUpdating = False
                For Each MyCell In UsedRange
                    If MyCell.Interior.ColorIndex = 36 Then MyCell = ""
                Next
                [d2:e2].ClearContents
                Application.ScreenUpdating = True
                Exit Sub
            End If
        End If
        If Target.Address = "$F$2" Then
            If Not PreCell Is Nothing Then
                If MsgBox("恢复点击前数据吗?", vbYesNo) = vbYes Then
                    reCell = PreCell - 1
                    Exit Sub
                End If
            End If
        End If
        If Target.Interior.ColorIndex = 36 Then
            Target = Target + 1
            Set PreCell = Target
        End If
    End If
End Sub
回复

使用道具 举报

 楼主| 发表于 2010-1-4 16:22 | 显示全部楼层

问题已解决,十分感谢amulee老师。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-6-6 15:09 , Processed in 0.551969 second(s), 6 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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