+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18

Thread: Message box macro not working

  1. #16
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Message box macro not working

    Another way:
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim cell        As Range
        Dim i           As Long
    
        With Range("H104, L104, P104, T104, X104")
            If Application.Intersect(Target, .Cells) Is Nothing Then Exit Sub
            For Each cell In .Cells
                i = i + 1
                If Abs(Target.Value - Target.Offset(, -2).Value) > 0.02 Then
                    MsgBox "SCALE Check " & i & " HAS FAILED CALIBRATION AND MUST BE RECALIBRATED BEFORE IT CAN BE USED TO TAKE WEIGHTS"
                End If
            Next cell
        End With
    End Sub
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  2. #17
    Registered User
    Join Date
    06-02-2010
    Location
    Grand Rapids, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    64

    Re: Message box macro not working

    Thanks shg but when I ran the code I got a type mismatch error on this part
    If Abs(Target.Value - Target.Offset(, -2).Value) > 0.02 Then

  3. #18
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007, 2010
    Posts
    25,777

    Re: Message box macro not working

    Only if one of the values is not numeric ...
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0