Mega Code Archive

 
Categories / VisualBasic Script / Excel
 

Creates the chart with absolute reference and format it

Sub CreateOHCLChart()     Dim myChart As Chart     Dim Ser As Series     ActiveSheet.Shapes.AddChart(xlLineMarkers).Select     Set myChart = ActiveChart     myChart.SetSourceData Source:=range("Sheet1!$A$1:$E$33")     With myChart.SeriesCollection(1)         .MarkerStyle = xlMarkerStylePicture         .Fill.UserPicture ("C:\dash.gif")         .Border.LineStyle = xlNone         .MarkerForegroundColorIndex = xlColorIndexNone     End With     With myChart.SeriesCollection(2)         .MarkerStyle = xlMarkerStyleNone         .Border.LineStyle = xlNone     End With     With myChart.SeriesCollection(3)         .MarkerStyle = xlMarkerStyleNone         .Border.LineStyle = xlNone     End With     ' Format the Close series     Set Ser = myChart.SeriesCollection(4)     With Ser         .MarkerBackgroundColorIndex = 1         .MarkerForegroundColorIndex = 1         .MarkerStyle = xlDot         .MarkerSize = 9         .Border.LineStyle = xlNone     End With     ' Add High-Low Lines     myChart.SetElement (msoElementLineHiLoLine)     myChart.SetElement (msoElementLegendNone) End Sub