I'm running this script. The goal is to put two data series into the plot area, which works. Values are random.
Option Explicit
Sub LWAs_Erzeugen()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim ws As Worksheet: Set ws = wb.Sheets("B3 Graph")
With ActiveSheet.ChartObjects("Chart 2").Select
ActiveChart.PlotArea.Select
ActiveChart.FullSeriesCollection(2).Delete
Application.CutCopyMode = False
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(1).Name = "=""LWA_aus_B1"""
ActiveChart.FullSeriesCollection(1).XValues = "='B2 PV Production'!$B$43:$BX$43"
ActiveChart.FullSeriesCollection(1).values = "='B2 PV Production'!$B$46:$BX$46"
ActiveChart.FullSeriesCollection(2).Delete
Application.CutCopyMode = False
ActiveChart.SeriesCollection.NewSeries
ActiveChart.FullSeriesCollection(2).Name = "=""LWA_aus_C0"""
ActiveChart.FullSeriesCollection(2).XValues = "='B2 PV Production'!$B$43:$BX$43"
ActiveChart.FullSeriesCollection(2).values = "='C0 EV (Historie)'!$D$3:$BZ$3"
ActiveChart.Axes(xlCategory).MinimumScale = Range("E14").value
ActiveChart.Axes(xlCategory).MaximumScale = Range("E15").value
End With
End Sub
ActiveChart.Axes(xlCategory).MinimumScale = Range("E14").value
ActiveChart.Axes(xlCategory).MaximumScale = Range("E15").value
Yes, I can do a with-block - but it doesn't work for me, I don't know why. Do not focus on that, please. The last two lines don't work as they should. What am I doing wrong? Instead of displaying an x-axis with dates as min/max values I get something else. The format is shown but no values!
Now the funky stuff: When I right-click and go to "select data" and click on any of the data series in the left list the dates appear! What is happening here?