#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Message Box

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Message Box

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,
--
AP

"srroduin" a écrit dans le message de
news: ...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Message Box

Works great! Thanks!

"Ardus Petus" wrote:

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,
--
AP

"srroduin" a écrit dans le message de
news: ...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace Excel Message w/Custom Message Kevin R Excel Programming 1 May 18th 06 04:13 PM
Intercept/replace standard 'cell protected' message with my own message? KR Excel Programming 3 March 16th 06 02:31 PM
Opening an attachment of a message that has a message as attachmen vetron Excel Programming 0 January 30th 06 06:17 PM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM
Displaying a message in a message box without requiring user to click anything to proceed Android[_2_] Excel Programming 2 June 25th 04 06:44 PM


All times are GMT +1. The time now is 09:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"