After reviewing FAQ707-4811 and researching the issue I cant seem to be able to pick the correct object to change the color index and the border of my chart. I highlighted the offending code in Blue.Any help is appreciated.
Tom
Tom
Code:
Function AddChartSheet(strSheet As String, intTopDataRow As Integer, intBottomDataRow As Integer, intLastColumn As Integer, intPageCnt As Integer)
Dim cht As ChartObject
Dim rng As Range
Dim intFirstChartRow As Integer
Dim intLastChartColumn As Integer
Dim intLastChartRow As Integer
Dim strLocation As String
Dim strDataSource As String
Dim strSource2 As String
Dim chtChart As Chart
Dim strNameSource As String
'Set location of chart
intFirstChartRow = intBottomDataRow + 2
intLastChartRow = intFirstChartRow + 19
intLastChartColumn = intLastColumn - 1
strDataSource = ConvColLet(intLastColumn) & intTopDataRow & ":" & ConvColLet(intLastColumn) & intBottomDataRow
strLocation = "A" & intFirstChartRow & ":" & ConvColLet(intLastColumn) & intLastChartRow
strNameSource = "A" & intTopDataRow & ":" & "A" & intBottomDataRow
Set chtChart = Charts.Add
Set chtChart = chtChart.Location(WHERE:=xlLocationAsObject, Name:=strSheet)
With chtChart
'Set the chart type
.ChartType = xlColumnClustered
'Set the source data range for the chart.
.SetSourceData Source:=Sheets(strSheet).Range(strDataSource), PlotBy:= _
xlColumns
End With
With chtChart.Parent
.Top = Range("A" & intFirstChartRow).Top
.Width = Range(strLocation).Width
.Height = Range(strLocation).Height
.Left = Range("A1").Left
End With
'Remove Series Label
ActiveChart.Legend.Select
Selection.Delete
'Add XAxisDataSeries
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).XValues = Worksheets(strSheet).Range(strNameSource)
'Set up Font Structure for XValues
ActiveChart.Axes(xlCategory).Select
With Selection.TickLabels.Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
If intPageCnt = 3 Then .Size = 9
End With
'ColorIndex definitions
'Set up background color of chart
[Blue] With Selection.Interior [/Blue]
'Set Border color black and thin line
.ColorIndex = 1
.Background = xlAutomatic
.Weight = xlThin
.LineStyle = xlContinuous
'Set background color to white on chart
.ColorIndex = 2
.PatternColorIndex = 1
.Pattern = xlSolid
End With
'Reselect sheet so chart only is not printed
goXL.ActiveSheet.Select ("A4")
End Function