I found this code on this site for a particular cell
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1") > 0.5 Then
MsgBox "Discount too high"
End If
End Sub
But I was wondering if it is possible to make this work for an entire column rather than one particular cell?
Try this for your event code:
Private Sub Worksheet_Calculate()
Dim rr As Range, r As Range
Set rr = Range("A:A").Cells.SpecialCells(xlCellTypeFormulas)
For Each r In rr
If r.Value > 0.5 Then
MsgBox "Discount too high"
End If
Next r
End Sub
EDIT#1:
if you want to restrict the message to a single row, then remove the first sub and replace it with:
Private Sub Worksheet_Change(ByVal Target As Range)
rt = Target.Row
If Range("A" & rt) > 0.5 Then
MsgBox "Discount too high"
End If
End Sub
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다