Time stamp when a conditrion is met

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a spreadheet that has streaming stock data. The number are always
changing. I am looking for a way to put a time stamp in a cell when a stock
hits a certain price. I want to look at the spreadsheet at the end of the day
to see if and when the stock ever hit that price. Any ideas?
 
=IF(K1>345,NOW(),"")

where K1 is where you want the time and 345 ids the price - this could be
another cell ( change the cell for the price you want

=IF(K1>B1,NOW(),"")

format the cell (K1 in this case as time)
 
But the time would continuously change. I think you'll need code such as:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cell As Range
For Each cell In Range("A1:A200")
If cell >= 345 And cell.Offset(0, 1) = "" Then cell.Offset(0, 1) = Now
Next
End Sub

This says every time something changes on the sheet if any value in A1:A200
is equal to or goes above 345, then the cell in column B will have the
current time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top