Thursday, August 12, 2010

Excel Chart Types

Here's some simple code to get the actual chart type from Excel.
We are using this for our customized Chart Formatter using Excel Themes to color and doing funky things like making simple data labels for lines charts with the series name in the same color as the line.

'-----------------------------------------------------------
'
' Code created by Tom Bizannes - Sydney, Australia
'
'-----------------------------------------------------------
Public Function ChartType(lChartType As Long) As String
  Select Case lChartType
  Case 4, 63, 64, 65, 66, 67, -4101 'line charts
    ChartType = "line"
  Case 1, 76, 77, 78, 79, -4098, -4111 ' area charts
    ChartType = "area"
  Case 57, 58, 59, 60, 61, 62, 102, 103, 104, 109, 110, 111
    ChartType = "bar"
  Case 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 92, 93, 94, 95, 96, 97, 98, -4100, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112 ' column charts
    ChartType = "column"
  Case 5, 68, 69, 70, 71, -4102 ' pie charts
    ChartType = "pie"
  Case -4169, 72, 73, 74, 75
    ChartType = "scatter"
  Case 15, 87
    ChartType = "bubble"
  Case -4120, 80
    ChartType = "doughnut"
  Case -4151, 81, 82
    ChartType = "radar"
  Case 88, 89, 90, 91
    ChartType = "stock"
  Case 83, 84, 85, 86
    ChartType = "surface"
  Case Else
    MsgBox "This application doesn't cater for this type of chart.", vbInformation, "StandardiseChart"
    Exit Function
  End Select
End Function

Tom Bizannes - Sydney - Australia
If you want to see the Excel Chart Formatter for High Quality Presentations or making it easy for everyone in your company to make good looking charts for word or powerpoint then goto MacroView and ask.

No comments: