Link to home
Start Free TrialLog in
Avatar of Andreas Hermle
Andreas HermleFlag for Germany

asked on

run macro on selected charts (resizing the chart area as well as data labels)

Dear Experts:

for the selected charts on the active worksheet I would like to run the following VBA macro:

- Resize the charts to Width of 5 cm and Height of 9 cm
- Increase the size of the chart labels (all of them are pie charts) to 10 pt and font type 'Times New Roman'

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try

Sub Makro7() '
' Makro7 Makro
For Each wks In Workbooks
    wks.Activate
    For Each cht In ActiveSheet.ChartObjects
        'cht.Legend.Format.TextFrame2.TextRange.Font.Size = 10
        cht.Chart.SeriesCollection(1).DataLabels.Format.TextFrame2.TextRange.Font.Size = 10
        cht.Chart.ChartArea.Height = Application.CentimetersToPoints(5)
        cht.Chart.ChartArea.Width = Application.CentimetersToPoints(9)
    Next
Next
End Sub

Open in new window

Regards
Avatar of Andreas Hermle

ASKER

Hi Rgonzo,

thank you very much for your swift help. I will give your code a try soon, but as I can see all of the charts get worked on on the active worksheet.

I got charts on the active worksheet that should be left alone and only those charts that I selected by using the Shift-Key and clicking on them should be worked on. Is this possible, i.e. running the above macro just on selected charts ...

Regards, Andreas
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great, this did the trick. Thank you very much for your professional help. Regards,  Andreas