ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Manipulating Excel pie charts with VB (https://www.excelbanter.com/excel-programming/272503-re-manipulating-excel-pie-charts-vbulletin.html)

Andrew[_16_]

Manipulating Excel pie charts with VB
 
Your code worked fine for me, either from the VBE or via a cmd button.
My only suggestion is to make sure you have the correct chart number.
To avoid any confusion here you could refer to the chart as
ChartObjects("ChartName"). Get the chart name by clicking the chart
with the control key depressed.

Regards,
Andrew


"Gemma Batterby" wrote in message ...
I am trying to set up a command button which upon clicking
allows all the data labels of a pie chart to be set to a
certain font size.
The code is as follows:

Worksheets("Callouts Classification").ChartObjects
(chartNum).Chart.SeriesCollection(1).DataLabels
(labelNum).Font.Size = 6

where chartNum and labelNum are obviously variables. The
pie charts are created using the chart wizard and I am
simply manipulating them using some VB code. When the
code is run from the VB environment it works fine but when
I run the code by clicking the command button I get an
error message saying:

Runtime Error 1004
Unable to set the Size property of the Font class

Any ideas as to why this might be when clicking the
command button??



All times are GMT +1. The time now is 10:46 AM.

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