Charting data from a changing linked cell over time

elguapo23

New Member
Joined
Nov 6, 2008
Messages
8
Hello,

I am trying to chart data from a single cell that is changing over time. The cell is linked to another software program that provides its value. I would like to be able to chart the changes in its value either every time it changes or on some time interval (i.e. every 3 minutes).

Is there a way to do this?

Thank you for any help you can offer.
 
Thanks for your replies Mala,

Is there a way that we can achieve the same result with formula-based changes? The linked cell that I want to chart changes based on a formula, not manual entry.

Thanks for your help.
 
Upvote 0
Use the Workbook_SheetChange event.

Let us say:

We have a workbook (Book2) with 4 sheets - Sheet1, sheet2, Sheet3, Sheet4

Sheet1 contains a critical cell (A1) which we wish to track and which has the formula =Sheet3!A1

Sheet2 col A is where we wish to poke changing values for Sheet1!A1

When Sheet3!A1 changes (Sheet3!A1 is NOT a formula), the formula in Sheet1!A1 will update the value but will not trigger the WorksheetChange event.

We will devise a way to force the WorksheetChange event for Sheet1!A1 when the cell on which it is dependent (Sheet3!A1) changes.

In sheet4:
Define a range name "Addresses" which refers to Sheet4!A:B (cols A and B)

In col A input the (full) addresses of all precedent cells of all formula cells which you want to track and in col B put the corresponding (full) address for the formula cell itself. See the workbook below where the cells in our example are input:

Sheet4

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=1><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 126px"><COL style="WIDTH: 191px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD></TD><TD>A</TD><TD>B</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD>[Book2]Sheet3!$A$1</TD><TD>[Book2]Sheet1!$A$1</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">4</TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">5</TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">6</TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">7</TD><TD></TD><TD></TD></TR></TBODY></TABLE>

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4

In the ThisWorkbook module put the following code:
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  Dim cell As Range
  For Each cell In Target.Cells
    Addr = cell.Address(True, True, xlA1, True)
    Mtch = 0
    On Error Resume Next
    Mtch = WorksheetFunction.Match(Addr, Range("Addresses").Columns(1), 0)
    On Error GoTo 0
    If Mtch > 0 Then
      Set Rng = Range(Range("Addresses").Cells(Mtch, 2))
      If Rng.HasFormula Then Rng.Formula = Rng.Formula
    End If
  Next
End Sub

Notice the code senses change in Sheet3!A1, locates it with Addresses col 1 in row 1, reads the address in col 2 of this row and RE-INPUTS the formula in that cell. This re-input triggers the worksheet_change event which runs the code I posted earlier...

Whew!!!!
 
Upvote 0
Hi Mala,

Thanks for your work and your detailed reply. The problem that I'm having is that the precedent cell that the formula is based on is actually a formula itself, a linked cell from the external application. So i suppose technically the precedent cell is a cell in the external application. However, I dont think excel can sense the changes in this external cell. Is there any other way to make excel recognize the change in displayed value of the cell I want to chart?

Alternatively, it might work to simply copy the data from the cell I want to chart to the column over a certain time interval (i.e. every 5 minutes). I think that would be a way to track the values as well.

It would be great to have code that could create a sheet with a column with the time stamp and another with the data. Also, it would be good to be able to create multiple columns for multiple cells to be tracked.

If you have any insight into how to accomplish this it would be a great help.

Thank you again for all the help.
 
Upvote 0
Alternatively, it might work to simply copy the data from the cell I want to chart to the column over a certain time interval (i.e. every 5 minutes).


Here's the approach...

In the workbook insert a new worksheet - name it ChartData.
Set it up as shown below
In A1 put the header 'Time' - format col A as 'hh:mm:ss'
In B1, C1, D1..... put references to the cells whose values you wish to track.


ChartData

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=1><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 97px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD></TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD><TD>E</TD><TD>F</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD>Time</TD><TD style="TEXT-ALIGN: right">22</TD><TD style="TEXT-ALIGN: right">20</TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">4</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">5</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">6</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">7</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">8</TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD></TR></TBODY></TABLE>
<TABLE style="FONT-SIZE: 10pt; BORDER-LEFT-COLOR: #00ff00; BORDER-BOTTOM-COLOR: #00ff00; COLOR: #000000; BORDER-TOP-STYLE: groove; BORDER-TOP-COLOR: #00ff00; FONT-FAMILY: Arial; BORDER-RIGHT-STYLE: groove; BORDER-LEFT-STYLE: groove; BACKGROUND-COLOR: #fffcf9; BORDER-RIGHT-COLOR: #00ff00; BORDER-BOTTOM-STYLE: groove"><TBODY><TR><TD>Spreadsheet Formulas</TD></TR><TR><TD><TABLE style="FONT-SIZE: 9pt; FONT-FAMILY: Arial" cellSpacing=0 cellPadding=2 border=1><TBODY><TR style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #cacaca"><TD>Cell</TD><TD>Formula</TD></TR><TR><TD>B1</TD><TD>=Sheet1!A1</TD></TR><TR><TD>C1</TD><TD>=Sheet3!A1</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4


In the ThisWorkbook module sheet paste the following code:

Rich (BB code):
Private Sub Workbook_Open()
    UpdateValues
End Sub

In a regular module in the workbook, put the following code:

Rich (BB code):
Sub UpdateValues()
    Dim Wks As Worksheet
    Set Wks = Worksheets("ChartData")
    RCount = Wks.Rows.Count
    Set LastCell = Wks.Cells(1, Wks.Columns.Count).End(xlToLeft)
    CellCount = LastCell.Column - 1
    NewRow = Wks.Cells(RCount, 1).End(xlUp).Offset(1, 0).Row
    Wks.Cells(NewRow, 1) = Now
    Wks.Cells(NewRow, 2).Resize(1, CellCount).Value = Wks.Cells(1, 2).Resize(1, CellCount).Value
    Application.OnTime Now + TimeValue("00:00:10"), "UpdateValues"
End Sub

Save the file.

Next time you open the workbook, the values will update every 10 seconds - change the timevalue in the code (shown in red font) to the required interval (e.g. "00:05:00" for update at 5 minute intervals).

For your charts, use dynamic range names and set the series references from the data in the ChartData sheet.
 
Last edited:
Upvote 0
Here's what I got after a few cycles:

ChartData

<TABLE style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma,Arial; BACKGROUND-COLOR: #ffffff" cellSpacing=0 cellPadding=0 border=1><COLGROUP><COL style="FONT-WEIGHT: bold; WIDTH: 30px"><COL style="WIDTH: 97px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"><COL style="WIDTH: 64px"></COLGROUP><TBODY><TR style="FONT-WEIGHT: bold; FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center"><TD> </TD><TD>A</TD><TD>B</TD><TD>C</TD><TD>D</TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">1</TD><TD>Time</TD><TD style="TEXT-ALIGN: right">22</TD><TD style="TEXT-ALIGN: right">20</TD><TD> </TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">2</TD><TD style="TEXT-ALIGN: right">16:11:10</TD><TD style="TEXT-ALIGN: right">24</TD><TD style="TEXT-ALIGN: right">25</TD><TD> </TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">3</TD><TD style="TEXT-ALIGN: right">16:11:20</TD><TD style="TEXT-ALIGN: right">24</TD><TD style="TEXT-ALIGN: right">25</TD><TD> </TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">4</TD><TD style="TEXT-ALIGN: right">16:11:30</TD><TD style="TEXT-ALIGN: right">22</TD><TD style="TEXT-ALIGN: right">20</TD><TD> </TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">5</TD><TD style="TEXT-ALIGN: right">16:11:40</TD><TD style="TEXT-ALIGN: right">22</TD><TD style="TEXT-ALIGN: right">20</TD><TD> </TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">6</TD><TD style="TEXT-ALIGN: right">16:11:50</TD><TD style="TEXT-ALIGN: right">22</TD><TD style="TEXT-ALIGN: right">20</TD><TD> </TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">7</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR><TR style="HEIGHT: 17px"><TD style="FONT-SIZE: 8pt; BACKGROUND-COLOR: #cacaca; TEXT-ALIGN: center">8</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR></TBODY></TABLE>
<TABLE style="FONT-SIZE: 10pt; BORDER-LEFT-COLOR: #00ff00; BORDER-BOTTOM-COLOR: #00ff00; COLOR: #000000; BORDER-TOP-STYLE: groove; BORDER-TOP-COLOR: #00ff00; FONT-FAMILY: Arial; BORDER-RIGHT-STYLE: groove; BORDER-LEFT-STYLE: groove; BACKGROUND-COLOR: #fffcf9; BORDER-RIGHT-COLOR: #00ff00; BORDER-BOTTOM-STYLE: groove"><TBODY><TR><TD>Spreadsheet Formulas</TD></TR><TR><TD><TABLE style="FONT-SIZE: 9pt; FONT-FAMILY: Arial" cellSpacing=0 cellPadding=2 border=1><TBODY><TR style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #cacaca"><TD>Cell</TD><TD>Formula</TD></TR><TR><TD>B1</TD><TD>=Sheet1!A1</TD></TR><TR><TD>C1</TD><TD>=Sheet3!A1</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top