Advertisement
Guest User

sub1

a guest
Apr 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. Sub Charts1()
  2. ' This sub illustrates some of the properties of a chart. The chart already
  3. ' exists (was built with Excel's chart tools) on the Sales sheet.
  4. Dim message As String
  5. Dim chtObj As ChartObject
  6. Dim cht As Chart
  7. Dim ser As Series, serCount As Integer
  8. Dim axH As Axis, axV As Axis
  9.  
  10. Set chtObj = wsDistrict12.ChartObjects("District 12")
  11. Set cht = chtObj.Chart
  12. Set axH = cht.Axes(xlCategory)
  13. Set axV = cht.Axes(xlValue)
  14.  
  15. message = "Here are some properties of the chartobject." & vbCrLf
  16. With chtObj
  17. message = message & vbCrLf & "Left: " & .Left
  18. message = message & vbCrLf & "Top: " & .Top
  19. message = message & vbCrLf & "Height: " & .Height
  20. message = message & vbCrLf & "Width property: " & .Width
  21. message = message & vbCrLf & "Name: " & .Name
  22. End With
  23. MsgBox message, vbInformation
  24.  
  25. message = "Here are some properties of the chart." & vbCrLf
  26. With cht
  27. message = message & vbCrLf & "ChartType: " & .ChartType
  28. message = message & vbCrLf & "HasLegend: " & .HasLegend
  29. message = message & vbCrLf & "HasTitle: " & .HasTitle
  30. If .HasTitle Then _
  31. message = message & vbCrLf & "Title: " & .ChartTitle.Text
  32. message = message & vbCrLf & "Number of series plotted: " _
  33. & .SeriesCollection.Count
  34. End With
  35. MsgBox message, vbInformation
  36.  
  37. message = "Here are some properties of the series in the chart." & vbCrLf
  38. For Each ser In cht.SeriesCollection
  39. serCount = serCount + 1
  40. With ser
  41. message = message & vbCrLf & "Name of series " _
  42. & serCount & ": " & .Name
  43. message = message & vbCrLf & "MarkerSize for series " _
  44. & serCount & ": " & .MarkerSize
  45. message = message & vbCrLf & "MarkerBackgroundColor for series " _
  46. & serCount & ": " & .MarkerBackgroundColor
  47. message = message & vbCrLf & "MarkerForegroundColor for series " _
  48. & serCount & ": " & .MarkerForegroundColor
  49. message = message & vbCrLf & "MarkerStyle for series " _
  50. & serCount & ": " & .MarkerStyle
  51. message = message & vbCrLf
  52. End With
  53. Next
  54. MsgBox message
  55.  
  56. message = "Some properties of the horizontal axis:" & vbCrLf
  57. With axH
  58. message = message & vbCrLf & "Format of tick labels: " _
  59. & .TickLabels.NumberFormat
  60. If .HasTitle Then
  61. message = message & vbCrLf & "Title: " & .AxisTitle.Text
  62. message = message & vbCrLf & "Font size of title: " _
  63. & .AxisTitle.Font.Size
  64. Else
  65. message = message & vbCrLf & "Horizontal axis has no title."
  66. End If
  67. End With
  68. MsgBox message
  69.  
  70. message = "Some properties of the vertical axis:" & vbCrLf
  71. With axV
  72. If .HasTitle Then
  73. message = message & vbCrLf & "Title: " & .AxisTitle.Text
  74. message = message & vbCrLf & "Font size of title: " _
  75. & .AxisTitle.Font.Size
  76. Else
  77. message = message & vbCrLf & "Vertical axis has no title."
  78. End If
  79. message = message & vbCrLf & "Minimum scale: " & .MinimumScale
  80. message = message & vbCrLf & "Maximum scale: " & .MaximumScale
  81. End With
  82. MsgBox message
  83. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement