Message Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Column LR does not exist. I presume you want to check whole column J.

Use following test:
If Application.Countif(Worksheets("feuil1").columns("J"),"<0") Then

Cheers,
 
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
 
Works great! Thanks!

Ardus Petus said:
Column LR does not exist. I presume you want to check whole column J.

Use following test:
If Application.Countif(Worksheets("feuil1").columns("J"),"<0") Then

Cheers,
 

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