Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default capturing a cell value at a specific time of day

In answering my own question from yesterday, my
programmer wrote this code which will capture the value
of cell which is updating realtime, save for that day's
value and copy the formula to the next cell to
dynamically update for the next day. (for use with data
such as stock prices that are realtime)

ie sMacro recorded 1/13/2004 by jenko
'
' Keyboard Shortcut: Ctrl+j
'
DoAfterMarketUpdate

End Sub

Private Sub DoAfterMarketUpdate()
Call DoUpdateSingleCol(ThisWorkbook.Sheets("2004").Rang e
("SMHPriceCol"), _
ThisWorkbook.Sheets("2004").Range
("SMHValue").Address)
Call DoUpdateSingleCol(ThisWorkbook.Sheets("2004").Rang e
("SPYPriceCol"), _
ThisWorkbook.Sheets("2004").Range
("SPYValue").Address)

End Sub


Private Sub DoUpdateSingleCol(TargCol As Range,
ValueAddress)

Dim TargRange As Range
Dim TargCell As Range
'TargRange gets set to the top of the Date column
Set TargRange = ThisWorkbook.Sheets("2004").Range
("DateHeader").Offset(1, 0)
'Keep going down the Date column until you get to either
1) a blank cell or 2) a date that's = today
While (TargRange.Value < Date) And (TargRange.Value
< "") ' go to 1st non-blank cell that's = current date
in Date column
Set TargRange = TargRange.Offset(1, 0)
Wend
' if the cell we're now looking at has a bigger date than
today, today must not be in the column, so just leave
If (TargRange.Value Date) Or (TargRange.Value = "")
Then Exit Sub
' if we got here, we're good to go
'
'
' set TargCell to be the intersection of the Price Column
(SMH or SPY, according to subroutine argument)
' and the row that today's date is in
Set TargCell = Application.Intersect(TargCol,
TargRange.EntireRow)

' Now, set the value in TargCell to be the value in our
(SMH or SPY) price cell
TargCell.Value = ThisWorkbook.Sheets("2004").Range
(ValueAddress).Value
' Now, go down one cell
Set TargCell = TargCell.Offset(1, 0)
' and put the FORMULA from our price cell into TargCell
TargCell.Formula = ThisWorkbook.Sheets("2004").Range
(ValueAddress).Formula

End Sub



tock prices realtime)
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing Real Time Data Rob Excel Worksheet Functions 2 February 24th 10 04:44 AM
Capturing Trend Data over time WildWill Excel Discussion (Misc queries) 1 March 31st 09 12:53 PM
VB Code Required for Capturing Time TGV Excel Discussion (Misc queries) 4 February 14th 09 03:26 PM
Date Capturing by Time Ken Excel Discussion (Misc queries) 1 December 2nd 07 10:50 AM
capturing a cell value at a specific time of day Thomas Donino Excel Programming 1 January 13th 04 01:45 PM


All times are GMT +1. The time now is 02:44 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"