excel - MS excel VBA:消息框依赖于 Vlookup 结果
问题描述
我正在努力寻找正确的代码位,以便根据日期表在 Excel 中弹出一个消息框。我的工作簿包含一个用户选择自由选择日期范围的首页,如果任何日期对应于我的日期表中的日期,我需要我的工作簿弹出一条消息(我附上了一些屏幕截图以创建清晰的图片.
创建弹出框等任务。我非常满意,但是如果所选日期之间的任何日期记录了事件,我真的找不到只显示消息框的方法。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Application.EnableEvents = True
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("D6")
If Not Application.Intersect(KeyCells, Target.Range("A1:G25")) _
Is Nothing Then
Call EventFinder
End If
End Sub
结果
解决方案
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Application.EnableEvents = True
' The variable KeyCells contains the cells that will
' cause an alert when they are changed.
Set KeyCells = Range("E6")
If Not Application.Intersect(KeyCells, Target.Range("A1:G25")) _
Is Nothing Then
'Call Any Macro You Want
End If
End Sub
使用此代码,我可以在工作表中的单元格 E6 发生更改时启动宏!请注意,此代码需要插入到工作簿对象中!没有进入一个模块。可以将要调用的宏插入到模块中。
推荐阅读
- javascript - 理解“this”在两种不同情况下的使用
- javascript - 带有 onclick 动画的多个按钮 - 某些按钮未完成 setTimeout
- powerbi - PowerBI - 使用映射到单独表中 ID 的固定和可变计算的组合聚合多行
- python - 浮点除法与整数除法给出不同的答案
- javascript - 斐波那契数列 - 从 JavaScript 中的特定 # 开始
- javascript - 如何使用 NodeJS 删除 dynamoDb 中的嵌套项
- c - 在函数递归内传递双指针
- ios - 将 Sprite 添加到导致 EXC_BAD_ACCESS 的场景
- spring - application.properties spring boot 值注入
- python - 在尝试中返回相同的迭代,除了