Thread: Message Box
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Mike Q. Mike Q. is offline
external usenet poster
 
Posts: 49
Default Message Box

Does this help?
Sub FindNeg()

Dim LR As Long
Dim MyCells As Range

LR = Sheets("Outage").UsedRange.Rows.Count
Worksheets("Outage").Range("J10:J" & LR).Select
For Each MyCells In Selection
If MyCells < 0 Then
MsgBox ("Warning. There are negative MW values." & _
"Please recalculate using smaller MW values.")
Exit Sub
End If
Next MyCells

End Sub

--
Mike Q.


"srroduin" wrote:

I want a message box to display if any of the values in column J are
negative.

This is what I put, however, I get a run time error.

Dim LR As Long

LR = LastRow(Sheets("Outage"))

Dim ErrorMSG As String

If Worksheets("Outage").Range("J10: LR").Value = negative Then

ErrorMSG = MsgBox("Warning. There are negative MW values. Please
recalculate using smaller MW values.")

End If

Any suggestions?

Thanks