zoukankan      html  css  js  c++  java
  • EXCEL中自动检测当前单元格或上一单元格在列A中是否存在相同数据[原创]

    代码如下(添加到对应sheet中!):

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
        Dim i As Long
        i = 1
        Do Until Range("A" & i).Value = ""
            '情况一   START   当前单元格的上面一个单元格中的数据在列A中是否有相同的——(单元格失去焦点时自动检测,因为默认敲回车时焦点会移到下面一个单元格)
            'If Split(ActiveCell.Address, "$")(2) = 1 Then Exit Sub
            'If Range(Split(ActiveCell.Address, "$")(1) & (Split(ActiveCell.Address, "$")(2)) - 1).Value = Range("A" & i).Value And ActiveCell.Column <> 1 Then
            '    Range("A" & i).Interior.Color = RGB(200, 160, 35)
            '    Range(Split(ActiveCell.Address, "$")(1) & (Split(ActiveCell.Address, "$")(2)) - 1).Interior.Color = vbRed
            'End If
            '情况一   END
            '情况二   START   当前选中的单元格中的数据在列A中是否有相同的
            If ActiveCell.Value = Range("A" & i).Value And ActiveCell.Column <> 1 Then
                Range("A" & i).Interior.Color = RGB(200, 160, 35)
                ActiveCell.Interior.Color = vbRed
            End If
            '情况二   END
            i = i + 1
        Loop
    End Sub

  • 相关阅读:
    日志收集
    解决spawn-fcgi child exited with: 1
    confluence启动关闭
    Informatica 启动、停止工作流命令
    启动obiee
    oracle修改连接空闲自动断开
    ORA-00845: MEMORY_TARGET not supported on this system
    svn执行clean up命令时报错
    手游推广
    phonegap/cordova 升级版本
  • 原文地址:https://www.cnblogs.com/mic86/p/1764949.html
Copyright © 2011-2022 走看看