Chart & Visualization Issues

Create a Live Excel Chart with Current Time and Changing Values

Kushani NimanthikaKushani Nimanthika Dec 2, 2026 868 views

Question details

Create a chart that displays the current time and plots a value that changes every second.

Create a Live Excel Chart with Current Time and Changing Values
Product
Microsoft Excel
Device & OS
not provided
Scenario
Use cells A1 and B1 to capture the current time and changing value, then display their history in a chart.
Observed behavior
The chart should update as new time and value samples are recorded.
Before you start

Use a desktop version of Excel that supports VBA, and confirm that B1 receives a numeric value. If B1 depends on an external data source, configure that source to update independently; the macro only samples the value available in the cell.

Solution 1Recommended

Log Time and Values with VBA and Update an Excel Chart

Use this method to sample B1 approximately once per second and plot the recorded history against time.

The NOW() formula updates only when Excel recalculates. This macro writes a timestamp to A1, recalculates formulas, and appends the time and B1 value to a chart data table.

Application.OnTime scheduling is approximate and may be delayed while Excel is busy. The workbook must remain open for sampling to continue.

1
Prepare the worksheet

Rename the worksheet LiveData. Keep the changing numeric value in B1, enter Time in D1 and Value in E1, and leave the cells below those headers empty. Select A1 and use Home > Number Format to apply the custom format hh:mm:ss.

2
Insert a scatter chart

Select D1:E2, then choose Insert > Scatter (X, Y) and select a scatter chart with lines or markers. Ensure this is the first chart on the LiveData sheet. If needed, right-click the horizontal axis, choose Format Axis, and set its number format to hh:mm:ss.

3
Add the sampling macro

Open Developer > Visual Basic, choose Insert > Module, and paste this code: Public NextRun As Date Public IsRunning As Boolean Sub StartLiveChart() StopLiveChart IsRunning = True LogLiveValue End Sub Sub LogLiveValue() Dim ws As Worksheet Dim r As Long Set ws = ThisWorkbook.Worksheets("LiveData") ws.Range("A1").Value = Now Application.Calculate r = ws.Cells(ws.Rows.Count, "D").End(xlUp).Row + 1 ws.Cells(r, "D").Value = ws.Range("A1").Value ws.Cells(r, "D").NumberFormat = "hh:mm:ss" ws.Cells(r, "E").Value = ws.Range("B1").Value ws.ChartObjects(1).Chart.SetSourceData Source:=ws.Range("D1:E" & r) NextRun = Now + TimeSerial(0, 0, 1) Application.OnTime NextRun, "'" & ThisWorkbook.Name & "'!LogLiveValue" End Sub Sub StopLiveChart() On Error Resume Next If IsRunning And NextRun > 0 Then Application.OnTime NextRun, "'" & ThisWorkbook.Name & "'!LogLiveValue", Schedule:=False End If IsRunning = False NextRun = 0 On Error GoTo 0 End Sub

4
Save and start sampling

Use File > Save As to save the workbook as an Excel Macro-Enabled Workbook (.xlsm). Enable macros if prompted, then open Developer > Macros, select StartLiveChart, and choose Run.

5
Stop the chart updates

Before closing the workbook, open Developer > Macros, select StopLiveChart, and choose Run to cancel the scheduled update.

Log Time and Values with VBA and Update an Excel Chart
External data and chart history: The macro does not refresh an external connection. It logs the value currently in B1, so repeated values may appear if the source updates less often than the sampling interval. Logged rows continue to accumulate until you stop the macro.
Free Microsoft Office alternative

Work with Spreadsheet Charts in WPS Office

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface and support for Excel formats, making it easy to open existing workbooks and create charts. The Excel VBA scheduling solution above is specific to Microsoft Excel and is not guaranteed to run in WPS.

Create and edit charts from spreadsheet data.Open and save common Microsoft Excel formats, including XLSX.Use a familiar interface for a smoother transition from Excel.Access a free, lightweight office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't =NOW() update every second in Excel?

NOW() returns the current date and time when Excel recalculates; it does not start a one-second timer. Use a scheduling method such as VBA Application.OnTime if you need repeated updates.

How do I show only the time on the chart axis?

Right-click the horizontal axis, choose Format Axis, and set the number format to hh:mm:ss. The underlying values can still contain both the date and time.

Will the macro refresh the data source for B1?

No. It recalculates Excel formulas and samples the value in B1. Configure any external connection or data feed separately so that B1 receives new values.

Why do I need to save the workbook as XLSM?

The XLSM format preserves VBA macros. Choose File > Save As and select Excel Macro-Enabled Workbook, then enable macros when prompted if you trust the workbook.

Can the chart keep updating after I close the workbook?

No. The workbook must stay open for the scheduled VBA macro to run. Use Developer > Macros > StopLiveChart before closing it.