I have been trying to figure this out for a while and have found my solution, and thought I should share. Basically I was trying to create a graph in excel without having to reference the data from any cell values, this would create from there a static graph in the end. So here is the code I'm sure it will get its fair share of use.

ArrayGraph Code:
  1. Sub CreateHBG()
  2. Dim strSQL14, strSQL15, strSQL16 As String
  3. Dim hbsdate, hbedate
  4. Dim cnn10 As New ADODB.Connection
  5. Dim rst10 As New ADODB.Recordset
  6. Dim ctValues() As Variant
  7. Dim ctAxis() As String
  8. Dim chtChart As Chart
  9. Dim MyNewSrs As Series
  10. Dim e As Integer
  11.  
  12. 'Requires
  13. 'MS ADO 2.8 Library
  14. 'MS ADO Ext. 2.8 for DDL and Security
  15. 'MS Graph 12.0 Object Library
  16.  
  17. 'Select the sheet to run the import
  18. Sheets("Run").Select
  19.  
  20. 'HEAT connection string
  21. cnn10.CommandTimeout = 0
  22. cnn10.ConnectionTimeout = 0
  23. cnn10.Open _
  24. "PROVIDER=SQLOLEDB;DATA SOURCE=Server;UID=Username;PWD=Password;DATABASE=Database"
  25.  
  26. 'Select statement to find out when the first linked ticket was created (Also known as the start of the heatboard)
  27. strSQL14 = "SELECT TOP 1 a.RecvdDate as 'FirstLinked', a.RecvdTime " & _
  28. "FROM olsheat.heat_user.CallLog a " & _
  29. "WHERE a.CallID IN " & _
  30. "(SELECT b.CallID FROM " & _
  31. "olsheat.heat_user.HEATSGen c INNER JOIN " & _
  32. "olsheat.heat_user.HEATHot b ON c.SGName = b.HotName WHERE " & _
  33. "(c.SGCode LIKE 'H%') AND " & _
  34. "(b.CallID IS NOT NULL) AND " & _
  35. "(c.SGName = '0000004202'))" & _
  36. "Order By a.RecvdDate ASC"
  37.  
  38. rst10.Open strSQL14, cnn10, adOpenStatic
  39.  
  40. 'Hold the date in a string for later reference
  41. hbsdate = Format(rst10.Fields!FirstLinked, "mm/dd/yyyy")
  42. hbsdate = CDate(hbsdate)
  43.  
  44. rst10.Close
  45.  
  46. 'Select statement to find out when the last linked ticket was created
  47. strSQL15 = "SELECT TOP 1 a.RecvdDate as 'LastLinked', a.RecvdTime " & _
  48. "FROM olsheat.heat_user.CallLog a " & _
  49. "WHERE a.CallID IN " & _
  50. "(SELECT b.CallID FROM " & _
  51. "olsheat.heat_user.HEATSGen c INNER JOIN " & _
  52. "olsheat.heat_user.HEATHot b ON c.SGName = b.HotName WHERE " & _
  53. "(c.SGCode LIKE 'H%') AND " & _
  54. "(b.CallID IS NOT NULL) AND " & _
  55. "(c.SGName = '0000004202'))" & _
  56. "Order By a.RecvdDate DESC"
  57.  
  58. rst10.Open strSQL15, cnn10, adOpenStatic
  59.  
  60. 'Hold the date in a string for later reference
  61. hbedate = Format(rst10.Fields!LastLinked, "mm/dd/yyyy")
  62. hbedate = CDate(hbedate)
  63.  
  64. rst10.Close
  65.  
  66. e = 0
  67.  
  68. 'ReDim Preserve ctValues(e), ctAxis(e)
  69.  
  70. 'Loop until the end date has been added to the array
  71. Do Until hbsdate = hbedate + 1
  72.  
  73. strSQL16 = "SELECT a.RecvdDate, COUNT(a.CallID) 'Tickets' " & _
  74. "FROM olsheat.heat_user.CallLog a " & _
  75. "WHERE a.RecvdDate = '" & Format(hbsdate, "YYYY-MM-DD") & "' AND a.CallID IN " & _
  76. "(SELECT b.CallID FROM " & _
  77. "olsheat.heat_user.HEATSGen c INNER JOIN " & _
  78. "olsheat.heat_user.HEATHot b ON c.SGName = b.HotName WHERE " & _
  79. "(c.SGCode LIKE 'H%') AND " & _
  80. "(b.CallID IS NOT NULL) AND " & _
  81. "(c.SGName = '0000004202'))" & _
  82. "Group By a.RecvdDate"
  83.  
  84. rst10.Open strSQL16, cnn10, adOpenStatic
  85.  
  86. 'Set the array as blank
  87. ReDim Preserve ctValues(e), ctAxis(e)
  88.  
  89. If rst10.EOF Then
  90. ctAxis(e) = hbsdate
  91. ctValues(e) = "0"
  92. Else
  93. hbsdate = rst10.Fields!RecvdDate
  94. ctAxis(e) = Format(rst10.Fields!RecvdDate, "mm/dd/yyyy")
  95. ctValues(e) = rst10.Fields!Tickets
  96. End If
  97.  
  98. rst10.Close
  99.  
  100. hbsdate = DateAdd("d", 1, hbsdate)
  101.  
  102. 'Hold the value into the dynamic array since static cannot be used to determine the size
  103. ReDim Preserve ctValues(e), ctAxis(e)
  104.  
  105. e = e + 1
  106.  
  107. Loop
  108.  
  109. 'If the array holds more than one value create a graph otherwise do not
  110. If e > 1 Then
  111.  
  112. ActiveSheet.Shapes.AddChart.Select
  113.  
  114. Set MyNewSrs = ActiveChart.SeriesCollection.NewSeries
  115. With MyNewSrs
  116.         .Name = "Tickets"
  117.         .Values = Array(ctValues)
  118.         .XValues = Array(ctAxis)
  119.     End With
  120.    
  121. 'Charts require office 2007 due to style references
  122.     ActiveChart.ChartTitle.Text = "HEATBoard #" & "4202"
  123.     ActiveChart.ChartType = xlLine
  124.     ActiveChart.ChartStyle = 40
  125.     ActiveChart.Parent.RoundedCorners = True
  126.     ActiveChart.SetElement (msoElementLegendBottom)
  127.     ActiveChart.ChartArea.Border.Color = RGB(248, 161, 90)
  128.     ActiveChart.ChartArea.Border.Weight = xlThick
  129.     ActiveChart.Axes(xlCategory).TickLabelSpacing = 1
  130.     ActiveChart.Axes(xlCategory, xlPrimary).TickLabels.Orientation = 45
  131.     ActiveChart.Parent.Width = 500
  132.     ActiveChart.Parent.Height = 275
  133.    
  134. End If
  135.  
  136. End Sub