Chart.CategoryLabelLevel property (Excel)
Returns an XlCategoryLabelLevel constant referring to the level of where the category labels are being sourced from. Read/write Integer.
expression A variable that represents a Chart object.
If there is a hierarchy, 0 refers to the most parent level, 1 refers to its children, and so on. So, 0 equals the first level, 1 equals the second level, 2 equals the third level, and so on.
The following sample code uses the CategoryNameLevel property to set the chart category names from the previously created row.
Sheets(1).Range("C1:E1").Value2 = "Sample_Row1" Sheets(1).Range("C2:E2").Value2 = "Sample_Row2" Sheets(1).Range("A3:A5").Value2 = "Sample_ColA" Sheets(1).Range("B3:B5").Value2 = "Sample_ColB" Sheets(1).Range("C3:E5").Formula = "=row()" Dim crt As Chart Set crt = Sheets(1).ChartObjects.Add(0, 0, 500, 200).Chart crt.SetSourceData Sheets(1).Range("A1:E5") ' Set the series names to only use column B crt.SeriesNameLevel = 1 ' Use columns A and B for the series names crt.SeriesNameLevel = xlSeriesNameLevelAll ' Use row 1 for the category labels crt.CategoryLabelLevel = 0 ' Use rows 1 and 2 for the category labels crt.CategoryLabelLevel = xlCategoryLabelLevelAll
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.