Beware Wet Paint
New Member
- Joined
- Jul 9, 2013
- Messages
- 34
Can worksheet_change macros only be set up to automatically run in response to data changes? If there anyway to set it to respond to a command button?
Sub Check_Cell_Value()
'Modified 11/4/2018 3:27:43 PM EST
If Range("A1").Value > 5 Then MsgBox "the limit has been succeeded"
End Sub
Sub Check_Cell_Value()
'Modified 11/4/2018 4:27:30 PM EST
If Range("A1") > 5 Or Range("A3") > 5 Or Range("A5") > 5 Then MsgBox "the limit has been succeeded"
End Sub
Sub New_Check()
'Modified 11/4/2018 4:48:04 PM EST
Dim r As Range
Dim x As Long
x = 0
For Each r In Range("A1,A3,A5")
With r.Value
Select Case r.Value
Case Is > 5
x = x + 1
End Select
End With
Next
If x > 0 Then MsgBox "the limit has been succeeded"
End Sub
Brilliant thank you
Here is another way to do it:
Code:Sub New_Check() 'Modified 11/4/2018 4:48:04 PM EST Dim r As Range Dim x As Long x = 0 For Each r In Range("A1,A3,A5") With r.Value Select Case r.Value Case Is > 5 x = x + 1 End Select End With Next If x > 0 Then MsgBox "the limit has been succeeded" End Sub