excel - 如何将弹出窗口中的 ID 与 Excel 中的 VBA 对齐?
问题描述
我在 Excel 2010 中有一个数据库,列出了不同的测量设备。每件作品都有一个 ID,还有一些其他的东西是已知的。
Each entry line looks like this:
ID … … Need for a pop-up?
1 … … NO
2 … … YES
3 … … NO
4 … … NO
等等。
出于可用性或功能等信息,我创建了一个公式来总结这些信息,并对以下问题给出“是”或“否”的答案:“需要弹出警告吗?” 因此,每当有人想借出可能无法工作/不可用的设备时,应通过弹出窗口警告用户:“警告:ID 为 111 的设备。此仪表可能有缺陷/不可用。 "
我已经有一些代码,每次出现以下问题时都会给我一条弹出消息:“需要弹出窗口”回答为“是”,但我无法在弹出窗口的文本中对齐受影响部分的 ID -向上。
Sub POP_UP_if_defect()
'In Cells N6:N500 are the answers "YES" or "NO" listed
For Each Cell In Sheets ("Sheet X").Range("N6:N500")
If Cell.Value = "YES" Then
MsgBox "Warning: This device might be defect/not available!"
End If
Next
End Sub
提前感谢您对此提供的任何帮助!
解决方案
当cell
包含“YES”时,您必须从该行的“A”列获取 id。尝试这样的事情:
With Sheets("Sheet X")
For Each cell In .Range("N6:N500")
If cell.Value = "YES" Then
Dim id
id = .Cells(cell.row, 1)
MsgBox "Warning: device " & id & " might be defect/not available!"
End If
Next cell
End With
推荐阅读
- javascript - Chrome 扩展程序不会在新标签页上自动激活
- javascript - 在元素样式上设置 .cssText 时转换不起作用?
- c# - 如何在运行时编辑 app.xaml 文件?
- php - PHP AES-128-CBC 使用十六进制密钥进行编码
- c - 数组的前 2 个元素在 for 循环后不显示在输出中
- c# - 在将类保存到 xml 文件之前加密属性
- django - 在Django中的整个表(所有字段,所有列,所有行)中查找一个字符串
- php - 使用 gd 调整字体大小和填充以创建动态条形图
- c++ - 是否可以将成员作为指针继承?
- python - 我正在抓取沃尔玛,但是每当我输入带有要抓取的搜索 URL 的函数的参数时,当我尝试打印它时,我什么也得不到