I have a section of code that controls a spreadsheet and chart that I am displaying data and I'm trying to customize the appearance of the chart. The usual commands to adjust a chart in excel don't seem to work. I will post my code below. I'm trying to set the range and make the scale logarithmic and adjust the colors of each seriescollection and also the location of the legend. I haven't included all of the code, but the others parts put the correct numbers where they are supposed to be. This is the only part that I am having trouble with. Please let me know if anyone knows how to do this:
Code:
With DataAOF
' .ScreenUpdating = False
For I = 2 To 5
.Cells(I, 2) = Q(I)
.Cells(I, 3) = Pwssq(I) / 10 ^ 6
Next I
For I = 1 To 5
.Cells(I + 1, 5) = Q(I)
.Cells(I + 1, 6) = LSF(I) / 10 ^ 6
.Cells(I + 1, 8) = Q(I)
.Cells(I + 1, 9) = LSFsq(I) / 10 ^ 6
Next I
.Cells(1, 2) = "Measured"
.Cells(1, 5) = "Least Squares Fit"
.Cells(1, 8) = "Laminar Flow 1/n=1"
.Cells(2, 8) = AOFc(2)
End With
With AOFChart
.Charts.Add 'Makes a new chart
.DataSource = DataAOF
With .Charts(0)
.Type = chChartTypeScatterLine
.SeriesCollection.Add 'Put in a new series
With .SeriesCollection(0)
.SetData chDimSeriesNames, 0, "B1" 'Series name is "Cole"
.SetData chDimXValues, 0, "B2:B5"
.SetData chDimYValues, 0, "C2:C5"
End With
.SeriesCollection.Add 'Make a new series
With .SeriesCollection(1)
.SetData chDimSeriesNames, 0, "E1" 'Name new series "Least Squares Fit"
.SetData chDimXValues, 0, "E2:E6" 'Set x-values to xrange
.SetData chDimYValues, 0, "F2:F6" 'Set y-values to yrange
End With
.SeriesCollection.Add 'Make a new series
With .SeriesCollection(2)
.SetData chDimSeriesNames, 0, "H1" 'Name new series "Least Squares Fit"
.SetData chDimXValues, 0, "H2:H6" 'Set x-values to xrange
.SetData chDimYValues, 0, "G2:G6" 'Set y-values to yrange
End With
.HasLegend = True
.HasTitle = True 'Chart has a title
End With
' .ScreenUpdating = True
End With