Hello all,
I'm using the method described here: http://www.mrexcel.com/forum/showthread.php?t=211983&highlight=SetLinkOnData to log values from my DDE feed, only I've hacked it (using a little simple logic in lieu of my complete lack of VBA knowledge) to log multiple values.
The problem is that the values are updated across the row whenever any one of them changes, which makes things a little unwieldy for my purposes.
Would someone be kind enough to tell me how to separate the values out, such that an individual cell (and it's "Now" partner) is only appended on a change in its DDE link?
Here is what I did:
Private Const Bid_Quantity As String = "ESOTS|'SEP10 ALSI'!BIDQ"
Private Const Bid_Price As String = "ESOTS|'SEP10 ALSI'!BIDP"
Private Const Last_Price As String = "ESOTS|'SEP10 ALSI'!LASTP"
Private Const Ask_Price As String = "ESOTS|'SEP10 ALSI'!ASKP"
Private Const Ask_Quantity As String = "ESOTS|'SEP10 ALSI'!ASKQ"
Private Const Volume As String = "ESOTS|'SEP10 ALSI'!VOL"
Private Const RecordToSheetName = "Data"
Sub BeginRecordingUpdates()
ThisWorkbook.SetLinkOnData Bid_Quantity, "RecordUpdates"
ThisWorkbook.SetLinkOnData Bid_Price, "RecordUpdates"
ThisWorkbook.Sheets(RecordToSheetName).Cells.ClearContents
End Sub
Sub RecordUpdates()
Dim r As Long
With ThisWorkbook.Sheets(RecordToSheetName)
r = Application.WorksheetFunction.CountA(.Columns(1)) + 1
If r > 65535 Then StopRecordingUpdates
.Cells(r, 1).Value = ThisWorkbook.Sheets("DDE").Range("A2").Value
.Cells(r, 2).Value = Now
.Cells(r, 3).Value = ThisWorkbook.Sheets("DDE").Range("B2").Value
.Cells(r, 4).Value = Now
.Cells(r, 5).Value = ThisWorkbook.Sheets("DDE").Range("C2").Value
.Cells(r, 6).Value = Now
.Cells(r, 7).Value = ThisWorkbook.Sheets("DDE").Range("D2").Value
.Cells(r, 8).Value = Now
.Cells(r, 9).Value = ThisWorkbook.Sheets("DDE").Range("E2").Value
.Cells(r, 10).Value = Now
.Cells(r, 11).Value = ThisWorkbook.Sheets("DDE").Range("F2").Value
.Cells(r, 12).Value = Now
End With
End Sub
Sub StopRecordingUpdates()
ThisWorkbook.SetLinkOnData Bid_Quantity, ""
End Sub
I'm using the method described here: http://www.mrexcel.com/forum/showthread.php?t=211983&highlight=SetLinkOnData to log values from my DDE feed, only I've hacked it (using a little simple logic in lieu of my complete lack of VBA knowledge) to log multiple values.
The problem is that the values are updated across the row whenever any one of them changes, which makes things a little unwieldy for my purposes.
Would someone be kind enough to tell me how to separate the values out, such that an individual cell (and it's "Now" partner) is only appended on a change in its DDE link?
Here is what I did:
Private Const Bid_Quantity As String = "ESOTS|'SEP10 ALSI'!BIDQ"
Private Const Bid_Price As String = "ESOTS|'SEP10 ALSI'!BIDP"
Private Const Last_Price As String = "ESOTS|'SEP10 ALSI'!LASTP"
Private Const Ask_Price As String = "ESOTS|'SEP10 ALSI'!ASKP"
Private Const Ask_Quantity As String = "ESOTS|'SEP10 ALSI'!ASKQ"
Private Const Volume As String = "ESOTS|'SEP10 ALSI'!VOL"
Private Const RecordToSheetName = "Data"
Sub BeginRecordingUpdates()
ThisWorkbook.SetLinkOnData Bid_Quantity, "RecordUpdates"
ThisWorkbook.SetLinkOnData Bid_Price, "RecordUpdates"
ThisWorkbook.Sheets(RecordToSheetName).Cells.ClearContents
End Sub
Sub RecordUpdates()
Dim r As Long
With ThisWorkbook.Sheets(RecordToSheetName)
r = Application.WorksheetFunction.CountA(.Columns(1)) + 1
If r > 65535 Then StopRecordingUpdates
.Cells(r, 1).Value = ThisWorkbook.Sheets("DDE").Range("A2").Value
.Cells(r, 2).Value = Now
.Cells(r, 3).Value = ThisWorkbook.Sheets("DDE").Range("B2").Value
.Cells(r, 4).Value = Now
.Cells(r, 5).Value = ThisWorkbook.Sheets("DDE").Range("C2").Value
.Cells(r, 6).Value = Now
.Cells(r, 7).Value = ThisWorkbook.Sheets("DDE").Range("D2").Value
.Cells(r, 8).Value = Now
.Cells(r, 9).Value = ThisWorkbook.Sheets("DDE").Range("E2").Value
.Cells(r, 10).Value = Now
.Cells(r, 11).Value = ThisWorkbook.Sheets("DDE").Range("F2").Value
.Cells(r, 12).Value = Now
End With
End Sub
Sub StopRecordingUpdates()
ThisWorkbook.SetLinkOnData Bid_Quantity, ""
End Sub