i have a sheet with some sets of data, and i want to plot some of them.
the sheets columns are like this
Time X Y X RSS
at different times i want to plot different columns( X Y or Y Z RSS etc) but always using the time along the X axis.
i have created a form with a check box for each column. there are two different types of data- Scaled and Filtered. this plotting Sub should work for both.
the check box values are stored in ScaleX, FilterX etc.
NameOfSheet comes from a text box.
I have been looking at the code and it seems to be ok, but strange things are happening. Columns are being plotted when i did not check the box, like this
what should be plotted what is plotted
X Z X
Y Z Y
Z Z Z
RSS RSS RSS
X Y Z X Y
X Y Z Z X Y Z
Z RSS RSS Z RSS
X Y Z RSS RSS X Y Z RSS
Y RSS RSS Y RSS
I dont konw why this is happening.
Something that may be realevent is that in the form, the check boxes for X Y and Z are in a row, and RSS is below them. it seems to be that if anything from the top row is selected, that an extra Z is added in, or once the RSS is selected that an extra RSS series is added.
here is the code for it, i have not been using VBA long so if you spot any mistakes please let me know
thank you in advance
the sheets columns are like this
Time X Y X RSS
at different times i want to plot different columns( X Y or Y Z RSS etc) but always using the time along the X axis.
i have created a form with a check box for each column. there are two different types of data- Scaled and Filtered. this plotting Sub should work for both.
the check box values are stored in ScaleX, FilterX etc.
NameOfSheet comes from a text box.
I have been looking at the code and it seems to be ok, but strange things are happening. Columns are being plotted when i did not check the box, like this
what should be plotted what is plotted
X Z X
Y Z Y
Z Z Z
RSS RSS RSS
X Y Z X Y
X Y Z Z X Y Z
Z RSS RSS Z RSS
X Y Z RSS RSS X Y Z RSS
Y RSS RSS Y RSS
I dont konw why this is happening.
Something that may be realevent is that in the form, the check boxes for X Y and Z are in a row, and RSS is below them. it seems to be that if anything from the top row is selected, that an extra Z is added in, or once the RSS is selected that an extra RSS series is added.
here is the code for it, i have not been using VBA long so if you spot any mistakes please let me know
thank you in advance
Code:
Public Sub CalcGraph()
Application.ScreenUpdating = False
Range("A14").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.name = "TimeRange"
Range("B14").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.name = "XSelection"
Range("C14").Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.name = "YSelection"
Range("D14").Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.name = "ZSelection"
If ScaleRSS = True Or FilterRSS = True Then
Range("E14").Activate
Range(Selection, Selection.End(xlDown)).Select
Selection.name = "RSSSelection"
End If
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.Location Where:=xlLocationAsNewSheet, name:=NameOfSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Data"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Amplitude"
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
With ActiveChart.Axes(xlValue)
.Crosses = xlCustom
.CrossesAt = ActiveChart.Axes(xlValue).MinimumScale
End With
If ScaleX = True Or FilterX = True Then
ActiveChart.SeriesCollection.Add Source:=Sheets("New_Data").Range("XSelection")
End If
If ScaleY = True Or FilterY = True Then
ActiveChart.SeriesCollection.Add Source:=Sheets("New_Data").Range("YSelection")
End If
If ScaleZ = True Or FilterZ = True Then
ActiveChart.SeriesCollection.Add Source:=Sheets("New_Data").Range("ZSelection")
End If
If ScaleRSS = True Or FilterRSS = True Then
ActiveChart.SeriesCollection.Add Source:=Sheets("New_Data").Range("RSSSelection")
End If
ActiveChart.SeriesCollection(1).XValues = Range("TimeRange")
Application.ScreenUpdating = True
End Sub