ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through to stop on pie charts (https://www.excelbanter.com/excel-programming/303929-looping-through-stop-pie-charts.html)

Daniel Bonallack[_2_]

Looping through to stop on pie charts
 
Could someone please tell me how to loop through a
workbook and make the font of pie charts 8pt (and only
pie charts)?

Thanks in advance

Daniel

Jon Peltier[_7_]

Looping through to stop on pie charts
 
Daniel -

Your macro should look like this:

Sub PieChartFonts8pt()
Dim sh As Object
Dim ch As Chart
Dim cho As ChartObject

' Get Chart Sheets
For Each ch In ActiveWorkbook.Charts
Select Case ch.ChartType
Case xlPie, xlPieExploded, xl3DPie, xl3DPieExploded
ch.ChartArea.Font.Size = 8
End Select
Next

' Get Embedded Charts
For Each sh In ActiveWorkbook.Sheets
For Each cho In sh.ChartObjects
Select Case cho.Chart.ChartType
Case xlPie, xlPieExploded, xl3DPie, xl3DPieExploded
cho.Chart.ChartArea.Font.Size = 8
End Select
Next
Next
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Daniel Bonallack wrote:

Could someone please tell me how to loop through a
workbook and make the font of pie charts 8pt (and only
pie charts)?

Thanks in advance

Daniel




All times are GMT +1. The time now is 05:08 AM.

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