MsgBox Question - HELP!

  • Thread starter Thread starter Ann
  • Start date Start date
A

Ann

I need to set up a warning message box that appears if a
value exceeds 80. I need the message to say something
like..."Warning, hours exceed limitation, Do you want to
continue?" If they do, then they will be allowed to enter
in the amount, if not, then they screen will just go back
to how it was before they entered to high number.
Can anyone help me on this? My code is not working.
 
Hi Ann
try the following code for cell A1

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Static Save_old_cell
Dim msg_return
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
On Error GoTo CleanUp
With Target
If .Value > 80 Then
msgreturn = MsgBox("Value is too large - Continue?",
vbOKCancel)
If msgreturn = 2 Then
Application.EnableEvents = False
.Value = Save_old_cell
End If
End If

Save_old_cell = .Value
End With
CleanUp:
Application.EnableEvents = True
End Sub

HTH
Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top