gpt4 book ai didi

vba - 当特定列的单元格更改时显示消息

转载 作者:行者123 更新时间:2023-12-03 01:41:09 24 4
gpt4 key购买 nike

我是 Excel VBA 新手。我想在 K 列中的任何单元格发生更改时显示警告消息。
我写了这段代码:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim row As Integer
Dim lrow As Long
With ActiveSheet
lrow = .Range("K" & .Rows.Count).End(xlUp).row

For satir = 5 To lrow
If Cells(row, 11).Value > 400 And Cells(row, 12).Value = "" Then
MsgBox _
("Risk Point of your operation is still high, Please Identify Contingency Plan")
End If
Next row

For row = 5 To lrow
If Cells(row, 22).Value > 200 And Cells(row, 24).Value = "" Then
MsgBox ("Risk Point is very high, Please Identify your Mitigation Plan")
End If
Next row
End With

End Sub

此代码可以正常工作,但会显示有关工作表中所做的所有更改的警告消息。

最佳答案

将其写入您的 Worksheet_Change Sub:

 If Target.Column = 11 Then
MsgBox "warning"
End If

一旦用户更改 k 列中的值,就会发送“警告”

关于vba - 当特定列的单元格更改时显示消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47588498/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com