I've got a large set of data that I'm trying to go through to dynamically make a chart out of. Each column value is aligned with a specific time value. There is a column called "Type" that hold either an empty cell, "Log ", "Log+", "SRst", "ARst", or "WRst" that I'm looking to plot onto the chart along with other user-defined columns in a specified time range.
So far I can get the chart to plot properly, but no matter the X time value, it always shows up at the first index time value, then the second, then third and so on up until the n'th appearance of that "Type" value.
Here is what I have right now and I'm not sure why it isn't aligning them to the appropriate values:
' This entire section is in a With block for the chart in another sub with the sub check in it's own sub
' I just felt like it's extra unnecessary stuff to add
Dim c4X As Range
Dim c5X As Range
Dim c6X As Range
Dim c7X As Range
Dim c8X As Range
' yFollow is the column that the events (c4-8X) are plotted on the Y axis with
' sh is the worksheet
For Each c In sh.Range(evChar & sIndex & ":" & evChar & eIndex)
If c.Value = "Log " Then
Call check(c.Row, yFollow, sh, c4X)
ElseIf c.Value = "Log+" Then
Call check(c.Row, yFollow, sh, c5X)
ElseIf c.Value = "SRst" Then
Call check(c.Row, yFollow, sh, c6X)
ElseIf c.Value = "ARst" Then
Call check(c.Row, yFollow, sh, c7X)
ElseIf c.Value = "WRst" Then
Call check(c.Row, yFollow, sh, c8X)
End If
Next c
' I'm aware this is a poor way, just make a function. I will change it after I figure this out
If Not c4X Is Nothing Then
.SeriesCollection(i).XValues = c4X
End If
If Not c5X Is Nothing Then
.SeriesCollection(i + 1).XValues = c5X
End If
If Not c6X Is Nothing Then
.SeriesCollection(i + 2).XValues = c6X
End If
If Not c7X Is Nothing Then
.SeriesCollection(i + 3).XValues = c7X
End If
If Not c8X Is Nothing Then
.SeriesCollection(i + 4).XValues = c8X
End If
Sub check(ByVal c As Long, ByVal col As String, ByVal sh As Worksheet, ByRef xRng As Range)
If xRng Is Nothing Then
Set xRng = sh.Range("A" & c)
Else
Set xRng = Union(xRng, sh.Range("A" & c))
End If
End Sub
You can see in excel the values are the starting time for some reason here. When hovering a point, here you can see the actual time value it should be. The graph as a whole looks like this. The ARst point on the graph is starting at 12:40:00. When hovering, it shows the value is 12:40:21. When right clicking the graph and selecting data, it shows the values to be 12:40:00-12:40:02.
I'm really unsure why when I'm setting the values that it's correct on point hovers, but not when it's actually plotted.