Results 1 to 10 of 10

Macro that will test values and require input if outside given ranges

Threaded View

  1. #1
    Registered User
    Join Date
    03-06-2013
    Location
    London, Canada
    MS-Off Ver
    Excel 2007
    Posts
    7

    Macro that will test values and require input if outside given ranges

    I am working on a project in which I need a series of values in the "B" column to be tested to see if each value entered is within the given range specified for that cell. If it is not then I would like the program to require some explanation to be entered in the adjacent "C" column.

    Here is a Macro that does exactly what I want it to for "B16". I however cannot seem to get it to work for other values in the "B" column.


    Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B16")) Is Nothing Then Exit Sub
    Dim CellVal
    If (Target < 150 Or Target > 180) And IsEmpty(Target.Offset(0, 1)) Then
    CellVal = InputBox("Oil Tempurature is Outside Suggested Range. Please Leave Comment (e.g. What corrective action was taken)")
    If CellVal = vbNullString Then GoTo error
    Target.Offset(0, 1) = CellVal
    End If
    error:
    If (Target < 150 Or Target > 180) And IsEmpty(Target.Offset(0, 1)) Then
    CellVal = InputBox("You must leave a Comment (e.g. What corrective action was taken)")
    If CellVal = vbNullString Then GoTo error
    Target.Offset(0, 1) = CellVal
    End If
    End Sub
    please HELP!!
    Last edited by NovoRapid; 05-15-2013 at 02:03 PM.

Thread Information

Users Browsing this Thread

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

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.6.0 RC 1