Hello,
I am trying to write some VBA code that will check a cell value and display a message box warning if it is below a certain threshold. the key here is that I want the message box to display only once. I figured to do this I would have to write some values in a hidden cell and check those values to see if the message has been displayed.
This is what I have so far:
I'm getting a "subscript out of range" error when I try to run the code, but I'm not sure what that means or why it's happening. Any thoughts?
Thanks!
I am trying to write some VBA code that will check a cell value and display a message box warning if it is below a certain threshold. the key here is that I want the message box to display only once. I figured to do this I would have to write some values in a hidden cell and check those values to see if the message has been displayed.
This is what I have so far:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim maxRange As Worksheet
Dim maxCell As Range
Set maxRange = ThisWorkbook.Sheets("Sheet4")
Set maxCell = maxRange.Range("C19")
For Each cell In Range("F22")
If maxCell.Value <> 1 Then
Select Case cell.Value
Case Is >= 5
Case Is = ""
Case Else
Application.EnableEvents = False
cell.Select
MsgBox ("blah blah blah")
Application.EnableEvents = True
Set maxCell.Value = 1
End Select
End If
Next cell
End Sub
I'm getting a "subscript out of range" error when I try to run the code, but I'm not sure what that means or why it's happening. Any thoughts?
Thanks!