Needing help with Input box and selecting from Range. RRS feed

  • Question

  • I am struggling with writing code for a stock watch, whereby a currency is entered into a user box, then when the user entry is exceeded by the stock price (which are listed in a column range B) it indicates the time that this price was exceeded with are highlighted in a range in column A.  Any help would be appreciated.
    Sunday, February 19, 2012 4:31 PM


  • Here is something that you can begin with:

    Sub PriceCheck()
    Price = Application.InputBox(Prompt:="Enter Price", Type:=1)
    For I = 1 To Cells(Rows.Count, "B").End(xlUp).Row
        If Cells(I, 2).Value > Price Then
            MsgBox "Price was exceeded " & Format(Cells(I, 1).Value, "mm-dd-yyyy hh:mm:ss")
            Exit Sub
        End If
    MsgBox "Price has not yet been exceeded"
    End Sub

    Price looked up in col B and the date/time returned from column A


    Monday, February 20, 2012 1:00 AM