Apply Number format of 1 decimal to datalabels of specific series in certain chart, certain sheet in certain workbook
Sub ChartLabelsNumberFormat(ChartName, SeriesNo, Optional NewNumberFormat = "#,##0.0", Optional WB = "This", Optional Shee = "Active")
' Apply Number format of 1 decimal to datalabels of specific series in certain chart, certain sheet in certain workbook
If WB = "This" Then WB = Thisworkbook.name
If Shee = "Active" Then Shee = Workbooks(WB).ActiveSheet.Name
Workbooks(WB).Activate
Workbooks(WB).Worksheets(Shee).Activate
ActiveSheet.ChartObjects(ChartName).Select
' Try either ...
ActiveChart.FullSeriesCollection(SeriesNo).DataLabels.NumberFormat = NewNumberFormat ' "#,##0.0"
' Or ...
ActiveChart.FullSeriesCollection(SeriesNo).DataLabels.Select
Selection.NumberFormat = NewNumberFormat ' "#,##0.0"
ActiveSheet.Range("A1").Select
' ActiveChart.FullSeriesCollection(2).Select
' ActiveChart.FullSeriesCollection(2).DataLabels.Select
' Selection.NumberFormat = "#,##0.00"
' ActiveSheet.ChartObjects("Chart 135").Legend.Width = 903.48
End Sub
' Apply Number format of 1 decimal to datalabels of specific series in certain chart, certain sheet in certain workbook
If WB = "This" Then WB = Thisworkbook.name
If Shee = "Active" Then Shee = Workbooks(WB).ActiveSheet.Name
Workbooks(WB).Activate
Workbooks(WB).Worksheets(Shee).Activate
ActiveSheet.ChartObjects(ChartName).Select
' Try either ...
ActiveChart.FullSeriesCollection(SeriesNo).DataLabels.NumberFormat = NewNumberFormat ' "#,##0.0"
' Or ...
ActiveChart.FullSeriesCollection(SeriesNo).DataLabels.Select
Selection.NumberFormat = NewNumberFormat ' "#,##0.0"
ActiveSheet.Range("A1").Select
' ActiveChart.FullSeriesCollection(2).Select
' ActiveChart.FullSeriesCollection(2).DataLabels.Select
' Selection.NumberFormat = "#,##0.00"
' ActiveSheet.ChartObjects("Chart 135").Legend.Width = 903.48
End Sub
ChartName, SeriesNo, Optional NewNumberFormat = "#,##0.0", Optional WB = "This", Optional Shee = "Active"
Views 256
Downloads 82
CodeID
DB ID