选择数据验证时的vba更改事件 [英] vba Change event when data validation selected

查看:38
本文介绍了选择数据验证时的vba更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个工作簿,在C列中有数据验证下拉列表.我使用tryinto代码,以便在淹没(即验证")列中选择特定状态时,我将自动输入未处理验证".第一列还具有数据验证和下拉列表.我到处搜索,似乎找不到从数据验证下拉列表中识别工作表更改事件的代码.谢谢!

Hi I have a workbook that in Column C there is data validation drop down list. I'm tryinto code so that when a specific status is selected in the drown down (i.e. "Verification") Column I will automatically enter "Verification Unprocessed". Column I also has data validation and a drop down list. I've searched all over and can't seem to find a code that identifies a worksheet change event from a data validation drop down list. Thanks!

推荐答案

您具有下拉列表的事实并不重要.无论单元格如何更改,都会触发工作表更改"事件.您需要做的就是检查事件中的 Target 变量是否在右列中,然后执行您需要做的事情.示例代码:

You fact that you have a drop-down list is not important. The Worksheet Change event will fire regardless of how the cell is changed. All you need to do is check if the Target variable in the event is in the right column, then do what you need to do. Sample code:

Private Sub Worksheet_Change(ByVal Target As Range)

    With Target
        If .Count = 1 Then
            If .Row > 1 And .Column = 3 Then
                If .Value = "specific status" Then
                    .Offset(0, 6).Value = "Verification Unprocessed"
                Else
                    .Offset(0, 6).ClearContents
                End If
            ElseIf .Column = 5 Then
                If .Value = Date Then
                   Call Lilly
                End If
            End If
        End If
    End With

End Sub

如果您需要更多信息,请告诉我.

Let me know if you need further information.

并入了原始代码.

这篇关于选择数据验证时的vba更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆