Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2003
    Thanked 0 Times in 0 Posts

    Simple Message Box Macro (Excel 2000)

    Is there a simple macro that would dispaly a warning message box if the value of a cell falls below number "x". I would like this macro to cover a whole range of cells for example (C1:C340) or the range named "Total Value" in the workbook. The message box could contain a botton saying "OK" allowing the user to continue to enter data after pressing it. Thanks in advance.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    South Carolina, USA
    Thanked 0 Times in 0 Posts

    Re: Simple Message Box Macro (Excel 2000)

    The easy thing would be to use Conditional Formatting to turn the cells red when the value falls below the minimum. If you want a warning message box, then you put code in the Worksheet Change or the Worksheet Calculate event routine depending on wheather the cell contains a constant or a formula.
    Legare Coleman

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Pittsburgh, Pennsylvania, USA
    Thanked 342 Times in 335 Posts

    Re: Simple Message Box Macro (Excel 2000)

    The foolwing code will check the desired range whenever the worksheet is changed and display a message FOR every cell in the totalvalue range that is < the value in the range named x.

    <pre>Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Dim rng As Range
    Dim rCell As Range
    Dim rValue As Range

    Set rng = Range("TotalValue")
    Set rValue = Range("x")

    For Each rCell In rng
    If rCell.Value < rValue.Value Then
    MsgBox ("Cell " & rCell.Address(False, False) & _
    " is less than " & rValue.Value)
    End If
    Next rCell
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts