RawlinsCross
Active Member
- Joined
- Sep 9, 2016
- Messages
- 437
I have a listbox on a userform that has a couple dozen entries, each entry corresponds to a column of data in a larger worksheet. Roughly the steps are:
#1 Find mrXValues from a set of two DTPickers
#2 Union mrXValues to mrTotal which will be used to graph
#3 Find the first series
#4 Union that series to MrTotal
#5 Repeat until all series from the listbox are sourced
#6 Plot the data
The listbox order Date,1,2,3,4,5,6
shows up in MrTotal as Date2,4,6,1,3,5
which makes it impossible to apply a legend using the Listbox.
Any thought as to what is going on?
Code:
#1 Find mrXValues from a set of two DTPickers
#2 Union mrXValues to mrTotal which will be used to graph
#3 Find the first series
#4 Union that series to MrTotal
#5 Repeat until all series from the listbox are sourced
#6 Plot the data
The listbox order Date,1,2,3,4,5,6
shows up in MrTotal as Date2,4,6,1,3,5
which makes it impossible to apply a legend using the Listbox.
Any thought as to what is going on?
Code:
Code:
Public Sub Plot1_Click()
Dim i As Long
Dim lIDCount As Long
Dim item As Variant
Dim lColNdx As Long
Dim sDataIdentifier As String
Set mrYValues = Nothing
Set mrTotal = Nothing
msICP = "Aqu_"
'finding the XData
Set mrXValues = rGetXValuesRange(wks:=mwks, _
dtStart:=Me.DTPicker1.Value, dtEnd:=Me.DTPicker2.Value)
Set mrTotal = mrXValues
'Series Data
For i = 0 To Me.Select_Analysis.ListCount - 1
sDataIdentifier = msICP & Me.Select_Analysis.List(i)
lColNdx = lGetHeaderColNumber(wks:=mwks, _
sDataIdentifier:=sDataIdentifier)
sDataIdentifier = msICP & mwks.Cells(1, lColNdx) & msSelectedElement
lColNdx = lGetHeaderColNumber(wks:=mwks, _
sDataIdentifier:=sDataIdentifier)
Set mrYValues = mrXValues.Offset(0, lColNdx - 1)
Set mrTotal = Union(mrTotal, mrYValues)
Next I
'Make Chart
If Not mrTotal Is Nothing Then
Call MakeChart
End If
'After this is a MakeChart() which plots the graph using
'Set myChart = ActiveSheet.Shapes.AddChart(xlXYScatter).Chart
'With myChart
' .SetSourceData Source:=mrTotal, PlotBy:=xlColumns
End Sub