How to assign x- axis values in ascending order from 0 to n?

60 Views Asked by At

I am trying to plot a temperature course automatically via VBA. Every measure point has a distance of one second to the next one.

I used the code shown below. My problem is that right now the first measure point is assigned to 1, the second to 2, etc. I would like to assign my first measure point to 0, my second to 1, etc.

Sub DiagramBlattErstellen()

'Variablen definieren
Dim MeinDiagrammBlatt As Chart
Dim Wertebereich As Range

Set Wertebereich = Worksheets("Unbenannt").Columns("H")

'Diagramm erstellen
Set MeinDiagrammBlatt = ThisWorkbook.Charts.Add2

'Werte zuweisen
MeinDiagrammBlatt.SetSourceData Source:=Wertebereich

'Name festlegen
MeinDiagrammBlatt.Name = "Vorlauftemperatur"

'Diagrammtyp
MeinDiagrammBlatt.ChartType = xlLine

Does anyone have any idea how to solve my problem?

1

There are 1 best solutions below

0
On

As an example, using Column G for axis labels and then add this:

'Werte zuweisen
MeinDiagrammBlatt.SetSourceData Source:=Wertebereich
MeinDiagrammBlatt.FullSeriesCollection(1).XValues = "==Unbenannt!$G:$G"