Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBA Excel-如果列中的某个值与我的条件匹配,则显示一条消息_Excel_Vba - Fatal编程技术网

VBA Excel-如果列中的某个值与我的条件匹配,则显示一条消息

VBA Excel-如果列中的某个值与我的条件匹配,则显示一条消息,excel,vba,Excel,Vba,我想创建一个宏,当我在excel工作表上工作时,它会在后台持续运行 函数:如果整列中的某个单元格=Now(),则显示一个消息框 有人能分享一下代码吗?把它放在你的工作表模块里 Private Sub Worksheet_SelectionChange(ByVal Target As Range) ' for a certain column - in this case G Dim Arr Arr = Split(Target.Address, "$")

我想创建一个宏,当我在excel工作表上工作时,它会在后台持续运行

函数:如果整列中的某个单元格=Now(),则显示一个消息框


有人能分享一下代码吗?

把它放在你的工作表模块里

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' for a certain column - in this case G
    Dim Arr
        Arr = Split(Target.Address, "$")
        If Arr(1) = "G" Then
            Beep
            MsgBox "You have selected column G..."
        End If

' for a certain row - in this case 2
    If Right(Target.Address, 2) = "$2" Then
        Beep
        MsgBox "You have selected Row 2..."
    End If

' for a certain cell - in this case A3
    If Target.Address = "$A$3" Then
        Beep
        MsgBox "You have selected Cell A3..."
    End If


End Sub

到目前为止你试过什么?你的意思是像公式中那样的
Now()
?还是单元格值时间值等于现在?无论如何,请读入
工作表\u Change
事件,并使用
Target.Column
查看修改的单元格是否位于某一列中,您不希望函数持续运行。对工作表模块中的工作表更改功能进行一些研究。然后,该函数将仅在该工作表发生更改时运行。您可以捕获要为其编写代码的列或单元格。现在()表示时间值。当然,我会研究改变的事情。基本上,我想写的代码可以做到这一点。每当列“B”中的一个单元格的时间值等于Now(),工作表就会自动显示一个msgbox,上面写着“请致电客户”。此表将由客户服务团队使用。