我需要帮助尝试编写excel VBA。有两个范围,H3:H100& A3:A100
我试图执行以下操作:
在工作簿打开上,如果范围H3中的单元格:H100 ="允许在7天内退出",则显示一个消息框,显示相应的" A&# 34;列单元格值说:"许可(列A单元格值)在7天后到期"
这是我的代码:
Private Sub Workbook_Open()
For Each cell In Range("I3:I100")
If cell.Value = "Y" And cell.Value <> "" Then
cell.Interior.ColorIndex = 15
cell.Font.ColorIndex = 10
cell.Font.Bold = True
ElseIf cell.Value = "N" And cell.Value <> "" Then
cell.Interior.ColorIndex = 22
cell.Font.ColorIndex = 2
cell.Font.Bold = True
End If
Next
For Each cell In Range("H3:H100")
If cell.Value = "PERMIT EXPIRES WITHIN 7 DAYS" And cell.Value <> "" Then
MsgBox "Permit (" & cell.Row & ":" & cell.Column & ") Expires in Seven Days", vbExclamation, "Alert"
End If
Next
End Sub
它确实有效,但它显示了交叉的行号和列号,而不是&#34; A&#34;中的实际单元格值。范围。
感谢任何帮助。
答案 0 :(得分:0)