ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   set datalabel font size for all charts in a row (https://www.excelbanter.com/excel-programming/317323-set-datalabel-font-size-all-charts-row.html)

Marie J-son[_4_]

set datalabel font size for all charts in a row
 
Hi,
This Sub doesn't work (why?)

I have a number of chartobjects with different numbers of datalabels and
seriecollections. How can I change font size for all charts and datalabels
in seriescollections all in a row?

Sub SetFonts()
Dim chtobj As ChartObjects
Dim scol As SeriesCollection
Dim dl As DataLabel
For Each chtobj In ActiveSheet
For Each scol In chtobj
For Each dl In scol
With dl.Font
.Name = "Arial"
.FontStyle = "Fet"
.Size = 16
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
.NumberFormat = "#,##0"
.AutoScaleFont = True
End With
Next
Next
Next
End Sub


Kind regards



John Green[_4_]

set datalabel font size for all charts in a row
 
Try the following:

Sub SetFonts()
Dim chtobj As ChartObject
Dim scol As Series
Dim dl As DataLabel
For Each chtobj In ActiveSheet.ChartObjects
For Each scol In chtobj.Chart.SeriesCollection
For Each dl In scol.DataLabels
With dl.Font
.Name = "Arial"
.FontStyle = "Fet"
.Size = 16
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
With dl
.NumberFormat = "#,##0"
.AutoScaleFont = True
End With
Next
Next
Next
End Sub


--
John Green
Sydney
Australia


"Marie J-son" wrote in message
...
Hi,
This Sub doesn't work (why?)

I have a number of chartobjects with different numbers of datalabels and
seriecollections. How can I change font size for all charts and datalabels
in seriescollections all in a row?

Sub SetFonts()
Dim chtobj As ChartObjects
Dim scol As SeriesCollection
Dim dl As DataLabel
For Each chtobj In ActiveSheet
For Each scol In chtobj
For Each dl In scol
With dl.Font
.Name = "Arial"
.FontStyle = "Fet"
.Size = 16
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
.NumberFormat = "#,##0"
.AutoScaleFont = True
End With
Next
Next
Next
End Sub


Kind regards






All times are GMT +1. The time now is 06:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com